Class: Airbrake::NestedException Private

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake-ruby/nested_exception.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A class that is capable of unwinding nested exceptions and representing them as JSON-like hash.

Since:

  • v1.0.4

Constant Summary collapse

MAX_NESTED_EXCEPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns the maximum number of nested exceptions that a notice can unwrap. Exceptions that have a longer cause chain will be ignored.

Returns:

  • (Integer)

    the maximum number of nested exceptions that a notice can unwrap. Exceptions that have a longer cause chain will be ignored

Since:

  • v1.0.4

3
RUBY_31_ERROR_HIGHLIGHTING_DIVIDER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

On Ruby 3.1+, the error highlighting gem can produce messages that can span multiple lines. We don’t display multiline error messages in the title of the notice in the Airbrake dashboard. Therefore, we want to strip out the higlighting part so that the errors look consistent. The full message with the exception will be attached to the notice body.

Returns:

  • (String)

Since:

  • v1.0.4

"\n\n".freeze
ENCODING_OPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns the options for String#encode.

Returns:

  • (Hash)

    the options for String#encode

Since:

  • v1.0.4

{ invalid: :replace, undef: :replace }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ NestedException

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NestedException.

Since:

  • v1.0.4



24
25
26
# File 'lib/airbrake-ruby/nested_exception.rb', line 24

def initialize(exception)
  @exception = exception
end

Instance Method Details

#as_jsonObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v1.0.4



28
29
30
31
32
33
34
# File 'lib/airbrake-ruby/nested_exception.rb', line 28

def as_json
  unwind_exceptions.map do |exception|
    { type: exception.class.name,
      message: message(exception),
      backtrace: Backtrace.parse(exception) }
  end
end