Gavin Sinclair
11/27/2003 6:24:00 AM
On Wednesday, November 26, 2003, 7:47:10 PM, Tobias wrote:
> Is there a way to tell ruby that it must never skip levels in the
> backtrace like this:
> /lib/ruby/1.8/net/ftp.rb:192:in `readline': End of file reached (EOFError)
> from /lib/ruby/1.8/net/ftp.rb:192:in `getline'
> from /lib/ruby/1.8/net/ftp.rb:202:in `getmultiline'
> from /lib/ruby/1.8/net/ftp.rb:216:in `getresp'
> from /lib/ruby/1.8/net/ftp.rb:232:in `voidresp'
> from /lib/ruby/1.8/net/ftp.rb:157:in `connect'
> from /lib/ruby/1.8/net/ftp.rb:155:in `synchronize'
> from /lib/ruby/1.8/net/ftp.rb:158:in `connect'
> from /lib/ruby/1.8/net/ftp.rb:119:in `initialize'
> ... 7 levels...
> from getp.rb:85:in `get_from'
> from getp.rb:85:in `open'
> from getp.rb:85:in `get_from'
> from getp.rb:120
If you catch the exception ('err') and 'puts err.backtrace', you'll
get the full story in the following form:
...
e.rb:7:in `b'
e.rb:3:in `a'
e.rb:7:in `b'
e.rb:3:in `a'
e.rb:7:in `b'
...
If you do a more complicated printing routine as Matz suggested, you
get this:
...
from e.rb:7:in `b'
from e.rb:3:in `a'
from e.rb:7:in `b'
from e.rb:3:in `a'
from e.rb:7:in `b'
from e.rb:3:in `a'
...
For information purposes, I'd just 'puts err.backtrace' and be done
with it. Note in both cases, the full trace is printed, not "..."!
Gavin