Class: Pry::LastException

Inherits:
BasicObject
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Kernel

blank_slate_method_added, #class_eval, concern, #double_late_addition, enable_warnings, #late_addition, method_added, preload_method_added, silence_warnings, suppress, with_warnings

Methods included from LateKernel

included, #late_kernel

Constructor Details

#initialize(exception) ⇒ LastException

Returns a new instance of LastException.



15
16
17
18
19
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 15

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 21

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

Instance Attribute Details

#bt_indexObject

Returns the value of attribute bt_index.



13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 13

def bt_index
  @bt_index
end

#fileString (readonly)

Returns the path to a file for the current backtrace. see #bt_index.

Returns:

  • (String)

    returns the path to a file for the current backtrace. see #bt_index.



37
38
39
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 37

def file
  @file
end

#lineFixnum (readonly)

Returns the line for the current backtrace. see #bt_index.

Returns:



43
44
45
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 43

def line
  @line
end

Instance Method Details

#bt_source_location_for(index) ⇒ Object



52
53
54
55
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 52

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

#inc_bt_indexObject



57
58
59
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 57

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

#respond_to_missing?(name, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 29

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

#wrapped_exceptionException

Returns the wrapped exception

Returns:

  • (Exception)

    returns the wrapped exception



48
49
50
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/last_exception.rb', line 48

def wrapped_exception
  @exception
end