class Airbrake::Backtrace

Front end to parsing the backtrace for each notice

Attributes

lines[R]

holder for an Array of Backtrace::Line instances

Public Class Methods

new(lines) click to toggle source
# File lib/airbrake/backtrace.rb, line 68
def initialize(lines)
  @lines = lines
end
parse(ruby_backtrace, opts = {}) click to toggle source
# File lib/airbrake/backtrace.rb, line 51
def self.parse(ruby_backtrace, opts = {})
  ruby_lines = split_multiline_backtrace(ruby_backtrace)

  filters = opts[:filters] || []
  filtered_lines = ruby_lines.to_a.map do |line|
    filters.inject(line) do |l, proc|
      proc.call(l)
    end
  end.compact

  lines = filtered_lines.collect do |unparsed_line|
    Line.parse(unparsed_line)
  end

  new(lines)
end

Private Class Methods

split_multiline_backtrace(backtrace) click to toggle source
# File lib/airbrake/backtrace.rb, line 94
def self.split_multiline_backtrace(backtrace)
  backtrace = [backtrace] unless backtrace.respond_to?(:to_a)
  if backtrace.to_a.size == 1
    backtrace.to_a.first.split(/\n\s*/)
  else
    backtrace
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/airbrake/backtrace.rb, line 84
def ==(other)
  if other.respond_to?(:lines)
    lines == other.lines
  else
    false
  end
end
inspect() click to toggle source
# File lib/airbrake/backtrace.rb, line 72
def inspect
  "<Backtrace: " + lines.collect { |line| line.inspect }.join(", ") + ">"
end
to_s() click to toggle source
# File lib/airbrake/backtrace.rb, line 76
def to_s
  content = []
  lines.each do |line|
    content << line
  end
  content.join("\n")
end