Sha256: ddbc02cd0deac2e511b0e92e3420276418d96eedfd8430649caa8f1283adc04f

Contents?: true

Size: 700 Bytes

Versions: 1

Compression:

Stored size: 700 Bytes

Contents

require 'rubygems'
require 'interception'
require 'pry'
require 'pry-stack_explorer'
def pryly(&block)
  raised = []

  Interception.listen(block) do |exception, binding|
    raised << [exception, binding.callers]
  end

ensure
  if raised.last
    e, bindings = raised.last
    $foo = e
    $bar = raised
    bindings.first.eval("_ex_ = $foo")
    bindings.first.eval("_raised_ = $bar")
    bindings = bindings.drop_while { |b| b.eval("self") == Interception || b.eval("__method__") == :pryly }
    pry :call_stack => bindings
  end
end

pryly do

  def a
    begin
      begin
        raise "foo"

      rescue => e
        raise "bar"
      end

    rescue => e
      1 / 0

    end
  end
  a
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
interception-0.1.pre.2 pryly.rb