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
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
···
On Wed, 28 Apr 2004, Scott Rubin wrote:
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’
…
Scott Rubin wrote:
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
jgb3@email.byu.edu
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”’