Sha256: e2dc335125cf412e832ec8e50bfde00267ff0d42381e5e1da0405d746d23195b

Contents?: true

Size: 1.21 KB

Versions: 20

Compression:

Stored size: 1.21 KB

Contents

#
# {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.
#
class Pry::LastException < BasicObject
  attr_accessor :bt_index

  def initialize(e)
    @e = e
    @bt_index = 0
    @file, @line = bt_source_location_for(0)
  end

  def method_missing(name, *args, &block)
    if @e.respond_to?(name)
      @e.public_send(name, *args, &block)
    else
      super
    end
  end

  def respond_to_missing?(name, include_all=false)
    @e.respond_to?(name, include_all)
  end

  #
  # @return [String]
  #  returns the path to a file for the current backtrace. see {#bt_index}.
  #
  def file
    @file
  end

  #
  # @return [Fixnum]
  #  returns the line for the current backtrace. see {#bt_index}.
  #
  def line
    @line
  end

  # @return [Exception]
  #   returns the wrapped exception
  #
  def wrapped_exception
    @e
  end

  def bt_source_location_for(index)
    backtrace[index] =~ /(.*):(\d+)/
    [$1, $2.to_i]
  end

  def inc_bt_index
    @bt_index = (@bt_index + 1) % backtrace.size
  end
end

Version data entries

20 entries across 20 versions & 8 rubygems

Version Path
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/last_exception.rb
xaiml-0.1.3 vendor/bundle/ruby/2.5.0/gems/pry-0.11.3/lib/pry/last_exception.rb
xaiml-0.1.2 vendor/bundle/ruby/2.5.0/gems/pry-0.11.3/lib/pry/last_exception.rb
xaiml-0.1.1 vendor/bundle/ruby/2.5.0/gems/pry-0.11.3/lib/pry/last_exception.rb
xaiml-0.1.0 vendor/bundle/ruby/2.5.0/gems/pry-0.11.3/lib/pry/last_exception.rb
monero_wallet_gen-0.1.0 vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/last_exception.rb
sb_prime_table-0.1.1 vendor/bundle/ruby/2.4.0/gems/pry-0.11.3/lib/pry/last_exception.rb
sb_prime_table-0.1.0 vendor/bundle/ruby/2.4.0/gems/pry-0.11.3/lib/pry/last_exception.rb
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/pry-0.11.2/lib/pry/last_exception.rb
comidita_ull-0.1.1 vendor/bundle/ruby/2.3.0/gems/pry-0.11.2/lib/pry/last_exception.rb
comidita_ull-0.1.0 vendor/bundle/ruby/2.3.0/gems/pry-0.11.2/lib/pry/last_exception.rb
pry-0.11.3 lib/pry/last_exception.rb
pry-0.11.3-java lib/pry/last_exception.rb
pry-0.11.2 lib/pry/last_exception.rb
pry-0.11.2-java lib/pry/last_exception.rb
tdiary-5.0.6 vendor/bundle/gems/pry-0.11.0/lib/pry/last_exception.rb
pry-0.11.1 lib/pry/last_exception.rb
pry-0.11.1-java lib/pry/last_exception.rb
pry-0.11.0 lib/pry/last_exception.rb
pry-0.11.0-java lib/pry/last_exception.rb