Exception#set_backtrace doesn't have any effect

  • Thread starter Simon Strandgaard
  • Start date
S

Simon Strandgaard

I want to attach debug information to some of my exceptions, however I
have problems transfering the backtrace array from the original to the new
exception. It seems as #set_backtrace doesn't have any effect?
What am I doing wrong?

Any suggestions how to do such thing?

I would have expected the output of following snippet to contain
these a:0:A b:1:B c:2:C entries.. but that doesn't happen.

server> ruby a.rb
a.rb:17:in `mk_problem': we got nuked (TolerantError)
from a.rb:19
server> expand -t2 a.rb
def trigger
raise "dodge this"
end
def dropbomb
trigger
end
def transportbomb
dropbomb
end
class TolerantError < StandardError; end
def mk_problem
transportbomb
rescue => e
#p e.backtrace
error = TolerantError.new("we got nuked")
error.set_backtrace(%w(a:0:A b:1:B c:2:C))
raise error
end
mk_problem
server>
 
Y

Yukihiro Matsumoto

Hi,

In message "Exception#set_backtrace doesn't have any effect"

|I want to attach debug information to some of my exceptions, however I
|have problems transfering the backtrace array from the original to the new
|exception. It seems as #set_backtrace doesn't have any effect?
|What am I doing wrong?
|
|Any suggestions how to do such thing?

It's a bug fixed in the latest CVS.

matz.
 
S

Simon Strandgaard

In message "Exception#set_backtrace doesn't have any effect"

|I want to attach debug information to some of my exceptions, however I
|have problems transfering the backtrace array from the original to the new
|exception. It seems as #set_backtrace doesn't have any effect?
|What am I doing wrong?
|
|Any suggestions how to do such thing?

It's a bug fixed in the latest CVS.

matz.

Thanks.. I better use cvs-head ;-)
 
S

Simon Strandgaard

Thanks.. I better use cvs-head ;-)

Installation via cvs went fine.. no problems.
Just a minor nitpick, maybe move the 'ri document generation'
from 'install' target to 'all' target?


Anyway, now #set_backtrace is working ;-)

server> ruby a.rb
a:0:A: we got nuked (TolerantError)
from b:1:B
from c:2:C
server> ruby -v
ruby 1.9.0 (2004-03-31) [i386-freebsd5.1]
server>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top