如何使从bar
最后一行重新引发的异常看起来像是来自那里,而不是来自块?我想bar
在回溯中看到。
begin
raise "foo"
rescue => e # yeah, i know
$e = e # oh boy, globals
end
sleep 1 # again, i know
def bar
raise $e
end
bar # => test.rb:2:in `<main>': foo (RuntimeError)
编辑:
当前的回溯是
test.rb:2:in `<main>': foo (RuntimeError)
我想要的是(或类似的东西)
test.rb:10:in `bar': foo (RuntimeError)
from test.rb:13:in `<main>'