class OpenSSL::OpenSSLError - Documentation for Ruby 4.0
Description: class OpenSSL::OpenSSLError: Generic error class for OpenSSL. All error classes in this library inherit from this class.
Keywords: ruby,class,OpenSSL::OpenSSLError

🔍

No recent searches

# class OpenSSL::OpenSSLError

Generic error class for `OpenSSL`. All error classes in this library inherit from this class.

This class indicates that an error was reported by the underlying OpenSSL library.

### Attributes

errors [R]

OpenSSL error queue entries captured at the time the exception was raised. The same information is printed to stderr if `OpenSSL.debug` is set to `true`.

This is an array of zero or more strings, ordered from the oldest to the newest. The format of the strings is not stable and may vary across versions of OpenSSL or versions of this Ruby extension.

See also the man page ERR_get_error(3).

### Public Instance Methods

detailed_message(**) → string
Source

    static VALUE
    osslerror_detailed_message(int argc, VALUE *argv, VALUE self)
    {
        VALUE str;
    #ifdef HAVE_RB_CALL_SUPER_KW
        // Ruby >= 3.2
        if (RTEST(rb_funcall(rb_eException, rb_intern("method_defined?"), 1,
                             ID2SYM(rb_intern("detailed_message")))))
            str = rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS);
        else
    #endif
            str = rb_funcall(self, rb_intern("message"), 0);
        VALUE errors = rb_attr_get(self, id_i_errors);

        // OpenSSLError was not created by ossl_make_error()
        if (!RB_TYPE_P(errors, T_ARRAY))
            return str;

        str = rb_str_resurrect(str);
        rb_str_catf(str, "\nOpenSSL error queue reported %ld errors:",
                    RARRAY_LEN(errors));
        for (long i = 0; i < RARRAY_LEN(errors); i++) {
            VALUE err = RARRAY_AREF(errors, i);
            rb_str_catf(str, "\n%"PRIsVALUE, err);
        }
        return str;
    }

Returns the exception message decorated with the captured OpenSSL error queue entries.