How can I force Ruby to show a full stack trace?

Željko Filipin picture Željko Filipin · Dec 19, 2008 · Viewed 39.4k times · Source

I just got this error message:

...
from c:/ruby/lib/ruby/gems/1.8/gems/...
 ... 10 levels...
from c:/ruby/lib/ruby/gems/1.8/gems/...
...

and the bug (of course) is hidden somewhere in ... 10 levels....

How can I force Ruby to show a full stack trace?

Answer

Željko Filipin picture Željko Filipin · Dec 19, 2008
begin
  # Code that raises exception
rescue StandardError => e
  puts e.backtrace
end