Can't see entire traceback

S

Scott Rubin

Hi,

I have a bug in one of my Ruby programs, and I'm having a hard time
fixing it. The problem isn't the bug itself, but the fact that Ruby
doesn't want to tell me where it is. Check this out.

When the program fails I get something like this
...
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:220:in `internal_parse'
... 9 levels...
from ./conf_curses.rb:51:in `mmenu'
...

The bug would be easy to fix, but the problem lies in my code somewhere
in those invisible 9 levels. How do I make ruby show all the levels of
the trace no matter what? I can probably fix this bug easily if I could
see which file it came from.

Thanks,

Scott
 
H

Hugh Sasse Staff Elec Eng

Hi,

I have a bug in one of my Ruby programs, and I'm having a hard time
fixing it. The problem isn't the bug itself, but the fact that Ruby
doesn't want to tell me where it is. Check this out.

When the program fails I get something like this
...
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:220:in `internal_parse'
... 9 levels...
from ./conf_curses.rb:51:in `mmenu'
...

I had similar with 19 levels once! I'd like this feature to be
optional, or at least have it not hide lines for code outside (the
default value of) $: anyway?

Hugh
 
J

Jamis Buck

Scott said:
Hi,

I have a bug in one of my Ruby programs, and I'm having a hard time
fixing it. The problem isn't the bug itself, but the fact that Ruby
doesn't want to tell me where it is. Check this out.

When the program fails I get something like this
...
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:220:in `internal_parse'
... 9 levels...
from ./conf_curses.rb:51:in `mmenu'
...

The bug would be easy to fix, but the problem lies in my code somewhere
in those invisible 9 levels. How do I make ruby show all the levels of
the trace no matter what? I can probably fix this bug easily if I could
see which file it came from.

Thanks,

Scott

If you catch the exception yourself, you can print all backtrace levels:

begin
do_something_that_barfs
rescue Exception => err
puts err.class.name + ": " + err.message
puts err.backtrace.join( "\n" )
end

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

ruby -h | ruby -e
'a=[];readlines.join.scan(/-(.)\[e|Kk(\S*)|le.l(..)e|#!(\S*)/) {|r| a <<
r.compact.first };puts "\n>#{a.join(%q/ /)}<\n\n"'
 

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
474,145
Messages
2,570,825
Members
47,371
Latest member
Brkaa

Latest Threads

Top