class Pry::LastException
{Pry::LastException} is a proxy class who wraps an Exception object for {Pry#last_exception}. it extends the exception object with methods that help pry commands be useful.
the original exception object is not modified and method calls are forwarded to the wrapped exception object.
Attributes
bt_index[RW]
Public Class Methods
new(e)
click to toggle source
# File lib/pry/last_exception.rb, line 12 def initialize(e) @e = e @bt_index = 0 @file, @line = bt_source_location_for(0) end
Public Instance Methods
bt_source_location_for(index)
click to toggle source
# File lib/pry/last_exception.rb, line 53 def bt_source_location_for(index) backtrace[index] =~ /(.*):(\d+)/ [$1, $2.to_i] end
file()
click to toggle source
@return [String]
returns the path to a file for the current backtrace. see {#bt_index}.
# File lib/pry/last_exception.rb, line 34 def file @file end
inc_bt_index()
click to toggle source
# File lib/pry/last_exception.rb, line 58 def inc_bt_index @bt_index = (@bt_index + 1) % backtrace.size end
line()
click to toggle source
@return [Fixnum]
returns the line for the current backtrace. see {#bt_index}.
# File lib/pry/last_exception.rb, line 42 def line @line end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/pry/last_exception.rb, line 18 def method_missing(name, *args, &block) if @e.respond_to?(name) @e.public_send(name, *args, &block) else super end end
respond_to_missing?(name, include_private = false)
click to toggle source
# File lib/pry/last_exception.rb, line 26 def respond_to_missing?(name, include_private = false) @e.respond_to?(name) end
wrapped_exception()
click to toggle source
@return [Exception]
returns the wrapped exception
# File lib/pry/last_exception.rb, line 49 def wrapped_exception @e end