Class: WebConsole::ExceptionMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/web_console/exception_mapper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ ExceptionMapper

Returns a new instance of ExceptionMapper.



23
24
25
26
27
# File 'lib/web_console/exception_mapper.rb', line 23

def initialize(exception)
  @backtrace = exception.backtrace
  @bindings = exception.bindings
  @exc = exception
end

Instance Attribute Details

#excObject (readonly)

Returns the value of attribute exc.



5
6
7
# File 'lib/web_console/exception_mapper.rb', line 5

def exc
  @exc
end

Class Method Details

.find_binding(mappers, exception_object_id) ⇒ Object



17
18
19
20
21
# File 'lib/web_console/exception_mapper.rb', line 17

def self.find_binding(mappers, exception_object_id)
  mappers.detect do |exception_mapper|
    exception_mapper.exc.object_id == exception_object_id.to_i
  end || mappers.first
end

.follow(exc) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/web_console/exception_mapper.rb', line 7

def self.follow(exc)
  mappers = [new(exc)]

  while cause = (cause || exc).cause
    mappers << new(cause)
  end

  mappers
end

Instance Method Details

#[](index) ⇒ Object



33
34
35
# File 'lib/web_console/exception_mapper.rb', line 33

def [](index)
  guess_binding_for_index(index) || @bindings[index]
end

#firstObject



29
30
31
# File 'lib/web_console/exception_mapper.rb', line 29

def first
  guess_the_first_application_binding || @bindings.first
end