class Failbot::Backtrace::Frame

A parsed stack frame.

Constants

FRAME_FORMAT

Regex adapted from sentry’s parser: github.com/getsentry/raven-ruby/blob/2e4378d95dae95a31e3386b2b94c8520649c6876/lib/raven/backtrace.rb#L10-L14

Attributes

abs_path[R]
file_name[R]
line_number[R]
method[R]

Public Class Methods

new(abs_path, file_name, line_number, method) click to toggle source
# File lib/failbot/backtrace.rb, line 80
def initialize(abs_path, file_name, line_number, method)
  @abs_path = abs_path
  @file_name = file_name
  @line_number = line_number
  @method = method
end
parse(unparsed_line) click to toggle source

Returns a Frame given backtrace component string or raises ParseError if it’s malformed.

# File lib/failbot/backtrace.rb, line 45
def self.parse(unparsed_line)
  match = unparsed_line.match(FRAME_FORMAT)
  if match
    abs_path, line_number, method = match.captures

    file_name = extract_file_name(abs_path)

    new(abs_path, file_name, line_number, method)
  else
    raise ParseError, "unable to parse #{unparsed_line.inspect}"
  end
end

Private Class Methods

extract_file_name(abs_path) click to toggle source
# File lib/failbot/backtrace.rb, line 61
def self.extract_file_name(abs_path)
  if Failbot.source_root
    abs_path.delete_prefix(Failbot.source_root)
  else
    abs_path
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/failbot/backtrace.rb, line 87
def to_s
  "#{file_name}:#{line_number}:in `#{method}'"
end