[MacRuby] #1214: Backtrace incorrect when exception is re-raised
MacRuby
ruby-noreply at macosforge.org
Fri Apr 1 15:19:48 PDT 2011
#1214: Backtrace incorrect when exception is re-raised
--------------------------------------+-------------------------------------
Reporter: warpflyght@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: major | Milestone:
Component: MacRuby | Keywords:
--------------------------------------+-------------------------------------
When re-raising an exception in MacRuby, the topmost frame in the
backtrace becomes the location of the "raise" used to re-raise, not the
location of the initial raise. Example program:
{{{
#!ruby
def demonstrate_bug
raise "Should Originate On Line #{__LINE__}"
rescue Exception
raise
end
demonstrate_bug
}}}
Example output:
{{{
$ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
$ ruby ./raise.rb
./raise.rb:2:in `demonstrate_bug': Should Originate On Line 2
(RuntimeError)
from ./raise.rb:7
$ ruby1.9 --version
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10]
$ ruby1.9 ./raise.rb
./raise.rb:2:in `demonstrate_bug': Should Originate On Line 2
(RuntimeError)
from ./raise.rb:7:in `<main>'
$ macruby --version
MacRuby 0.11 (ruby 1.9.2) [universal-darwin10.0, x86_64]
$ macruby ./raise.rb
/private/tmp/./raise.rb:4:in `demonstrate_bug': Should Originate On Line 2
(RuntimeError)
from /private/tmp/./raise.rb:7:in `demonstrate_bug'
}}}
Because the backtrace doesn't include frames above the rescue block, it
isn't useful for debugging re-raised exceptions. The workaround is to
capture the backtrace of the exception before re-raising (probably
printing it out yourself).
I'm using
[https://github.com/MacRuby/MacRuby/commit/c59dc4930d2b2166ee1527bb45914599553c5bba
commit c59dc4930d2b2166ee1527bb45914599553c5bba] on a 64-bit machine
running Mac OS X 10.6.7.
--
Ticket URL: <http://www.macruby.org/trac/ticket/1214>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list