From: Gavin Sinclair Date: 2003-11-27T15:23:50+09:00 Subject: Re: Backtrace without skips needed 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