class Airbrake::NestedException
@since v1.0.4
@api private
as JSON-like hash.
A class that is capable of unwinding nested exceptions and representing them
def as_json
def as_json unwind_exceptions.map do |exception| { type: exception.class.name, message: message(exception), backtrace: Backtrace.parse(exception) } end end
def initialize(exception)
def initialize(exception) @exception = exception end
def message(exception)
def message(exception) return unless (msg = exception.message) msg .encode(Encoding::UTF_8, **ENCODING_OPTIONS) .split(RUBY_31_ERROR_HIGHLIGHTING_DIVIDER) .first end
def unwind_exceptions
def unwind_exceptions exception_list = [] exception = @exception while exception && exception_list.size < MAX_NESTED_EXCEPTIONS exception_list << exception exception = (exception.cause if exception.respond_to?(:cause)) end exception_list end