aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-01-20 21:23:46 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-01-24 13:28:47 +0900
commit54db4a4abd22ee2ee204f473143c4ad23d894bc4 (patch)
treefbdb425cb7cfa6f0e712350feab01a4d1f5b14dd
parentc9225b0cbc5d6ce48e7d6172e2010f02b90e22c9 (diff)
downloadruby-openssl-54db4a4abd22ee2ee204f473143c4ad23d894bc4.tar.gz
Make exceptions with the same format regardless of OpenSSL.debug
As the current behavior is useless. If OpenSSL.debug is set to true, errors put to the error queue will be printed to stderr anyway.
-rw-r--r--ext/openssl/ossl.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index eb71b643..e4725f09 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -260,18 +260,15 @@ static VALUE
ossl_make_error(VALUE exc, const char *fmt, va_list args)
{
VALUE str = Qnil;
- const char *msg;
- long e;
+ unsigned long e;
- e = ERR_peek_last_error();
if (fmt) {
str = rb_vsprintf(fmt, args);
}
+ e = ERR_peek_last_error();
if (e) {
- if (dOSSL == Qtrue) /* FULL INFO */
- msg = ERR_error_string(e, NULL);
- else
- msg = ERR_reason_error_string(e);
+ const char *msg = ERR_reason_error_string(e);
+
if (NIL_P(str)) {
if (msg) str = rb_str_new_cstr(msg);
}
@@ -279,8 +276,8 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
if (RSTRING_LEN(str)) rb_str_cat2(str, ": ");
rb_str_cat2(str, msg ? msg : "(null)");
}
+ ossl_clear_error();
}
- ossl_clear_error();
if (NIL_P(str)) str = rb_str_new(0, 0);
return rb_exc_new3(exc, str);