Exception: Exception

Defined in:
lib/pry-exception_explorer/core_ext.rb

Overview

PryExceptionExplorer monkey-patches to Exception

Constant Summary collapse

NoContinuation =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#continuationContinuation

Returns The continuation object for the exception. Invoking this continuation will allow the program to continue from the point the exception was raised.

Returns:

  • (Continuation)

    The continuation object for the exception. Invoking this continuation will allow the program to continue from the point the exception was raised.



8
9
10
# File 'lib/pry-exception_explorer/core_ext.rb', line 8

def continuation
  @continuation
end

#exception_call_stackArray<Binding>

Returns The array of bindings that represent the call stack for the exception. This is navigable inside the Pry session with the up and down and frame commands.

Returns:

  • (Array<Binding>)

    The array of bindings that represent the call stack for the exception. This is navigable inside the Pry session with the up and down and frame commands.



13
14
15
# File 'lib/pry-exception_explorer/core_ext.rb', line 13

def exception_call_stack
  @exception_call_stack
end

#internal_exceptionBoolean Also known as: internal_exception?

Returns Whether this exception was raised internally. i.e from the C-level using rb_raise.

Returns:

  • (Boolean)

    Whether this exception was raised internally. i.e from the C-level using rb_raise



21
22
23
# File 'lib/pry-exception_explorer/core_ext.rb', line 21

def internal_exception
  @internal_exception
end

#should_interceptBoolean Also known as: should_intercept?

Returns Whether this exception should be intercepted. (Only relevant for wrapped exceptions).

Returns:

  • (Boolean)

    Whether this exception should be intercepted. (Only relevant for wrapped exceptions).



17
18
19
# File 'lib/pry-exception_explorer/core_ext.rb', line 17

def should_intercept
  @should_intercept
end

Instance Method Details

#continueObject

This method enables us to continue an exception (using callcc internally)

Raises:



26
27
28
29
# File 'lib/pry-exception_explorer/core_ext.rb', line 26

def continue
  raise NoContinuation unless continuation.respond_to?(:call)
  continuation.call
end

#exception(*args, &block) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pry-exception_explorer/core_ext.rb', line 33

def exception(*args, &block)
  if PryExceptionExplorer.enabled? &&
      PryExceptionExplorer.should_intercept_exception?(binding.of_caller(1), self) &&
      !caller.any? { |t| t.include?("raise") } && !exception_call_stack

    ex = old_exception(*args, &block)
    ex.exception_call_stack = binding.callers.drop(1)
    ex.set_backtrace(caller) if !ex.backtrace

    PryExceptionExplorer.amend_exception_call_stack!(ex)
    ex.should_intercept   = true
    ex.internal_exception = true

    if PryExceptionExplorer.inline?
      retval = PryExceptionExplorer.enter_exception(ex, :inline => true)
    end

    ex
  else
    old_exception(*args, &block)
  end
end

#old_exceptionObject



31
# File 'lib/pry-exception_explorer/core_ext.rb', line 31

alias_method :old_exception, :exception