Class: Captivus::Backtrace

Inherits:
Object
  • Object
show all
Defined in:
lib/captivus/backtrace.rb,
lib/captivus/backtrace/line.rb

Defined Under Namespace

Classes: Line

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ Backtrace

Returns a new instance of Backtrace.



5
6
7
8
9
10
# File 'lib/captivus/backtrace.rb', line 5

def initialize(exception)
  unless exception.respond_to?(:backtrace)
    raise ArgumentError, "#{exception} must respond to `backtrace`"
  end
  @exception = exception
end

Instance Method Details

#as_jsonObject



12
13
14
# File 'lib/captivus/backtrace.rb', line 12

def as_json(*)
  Array(exception.backtrace).map { |line| Line.new(line).as_json }
end