Module: Airbrake::Backtrace Private

Extended by:
Loggable
Defined in:
lib/airbrake-ruby/backtrace.rb

Overview

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

Represents a cross-Ruby backtrace from exceptions (including JRuby Java exceptions). Provides information about stack frames (such as line number, file and method) in convenient for Airbrake format.

Examples:

begin
  raise 'Oops!'
rescue
  Backtrace.parse($!)
end

Since:

  • v1.0.0

Defined Under Namespace

Modules: Patterns

Constant Summary collapse

CODE_FRAME_LIMIT =

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 how many first frames should include code hunks.

Returns:

  • (Integer)

    how many first frames should include code hunks

Since:

  • v1.0.0

10

Class Method Summary collapse

Methods included from Loggable

logger

Class Method Details

.java_exception?(exception) ⇒ Boolean

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.

Checks whether the given exception was generated by JRuby’s VM.

Parameters:

  • exception (Exception)

Returns:

  • (Boolean)

Since:

  • v1.0.0



106
107
108
109
110
111
112
113
114
115
# File 'lib/airbrake-ruby/backtrace.rb', line 106

def self.java_exception?(exception)
  if defined?(Java::JavaLang::Throwable) &&
     exception.is_a?(Java::JavaLang::Throwable)
    return true
  end

  return false unless exception.respond_to?(:backtrace)

  (Patterns::JAVA =~ exception.backtrace.first) != nil
end

.parse(exception) ⇒ Array<Hash{Symbol=>String,Integer}>

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.

Parses an exception’s backtrace.

Parameters:

  • exception (Exception)

    The exception, which contains a backtrace to parse

Returns:

  • (Array<Hash{Symbol=>String,Integer}>)

    the parsed backtrace

Since:

  • v1.0.0



96
97
98
99
100
# File 'lib/airbrake-ruby/backtrace.rb', line 96

def self.parse(exception)
  return [] if exception.backtrace.nil? || exception.backtrace.none?

  parse_backtrace(exception)
end