Class: Pry

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-capture/core_ext.rb

Class Method Summary collapse

Class Method Details

.capture(&block) ⇒ Object

Start a pry session on any unhandled exceptions within this block.

Examples:

Pry::capture do
  raise "foo"
end

Returns:

  • (Object)

    The return value of the block



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pry-capture/core_ext.rb', line 11

def self.capture(&block)
  raised = []

  Interception.listen(block) do |exception, binding|
    if defined?(PryStackExplorer)
      raised << [exception, binding.callers]
    else
      raised << [exception, Array(binding)]
    end
  end

rescue Exception => e
  PryCapture.enter_exception_context(raised)
  raise
end