Class: PryRescue
- Inherits:
-
Object
- Object
- PryRescue
- Defined in:
- lib/pry-rescue.rb,
lib/pry-rescue/rack.rb,
lib/pry-rescue/rails.rb
Overview
PryRescue provides the ability to open a Pry shell whenever an unhandled exception is raised in your code.
The main API is exposed via the Pry object, but here are a load of helpers that I didn’t want to pollute the Pry namespace with.
Defined Under Namespace
Class Method Summary collapse
-
.enter_exception_context(raised) ⇒ Object
Start a Pry session in the context of the exception.
-
.in_exception_context? ⇒ Boolean
Is the user currently inside pry rescue?.
-
.load(script) ⇒ Object
Load a script wrapped in Pry::rescue{ }.
Class Method Details
.enter_exception_context(raised) ⇒ Object
Start a Pry session in the context of the exception.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pry-rescue.rb', line 30 def enter_exception_context(raised) @exception_context_depth ||= 0 @exception_context_depth += 1 raised = raised.map do |e, bs| [e, without_bindings_below_raise(bs)] end raised.pop if phantom_load_raise?(*raised.last) exception, bindings = raised.last bindings = without_duplicates(bindings) if defined?(PryStackExplorer) pry :call_stack => bindings, :hooks => pry_hooks(exception, raised), :initial_frame => initial_frame(bindings) else Pry.start bindings.first, :hooks => pry_hooks(exception, raised) end ensure @exception_context_depth -= 1 end |
.in_exception_context? ⇒ Boolean
Is the user currently inside pry rescue?
61 62 63 |
# File 'lib/pry-rescue.rb', line 61 def in_exception_context? @exception_context_depth && @exception_context_depth > 0 end |