Ruby "better" unhandled exception output


#1

Inspired by some blog post, unroller, Tracer, and Python, I bring you.

backtracer

why: the default unhandled exception screen output is somewhat sparse:
ex:

ruby crash.rb
crash.rb:6:in go2': unhandled exception from crash.rb:11:ingo’
from crash.rb:15

The new backtracer, however:

ruby -rbacktracer crash.rb

unhandled exception: crash.rb:6: raise
locals: {“a”=>“3”, “b”=>3, “within_go2”=>4}
from:
crash.rb:1 go2(a=>3, b=>55)
locals: {“a”=>“3”, “b”=>3, “within_go2”=>4}
crash.rb:8 go(a=>3)
locals: {“a”=>“3”, “within_go”=>2}

How to use:

copy backtracer.rb to pwd from

http://github.com/rogerdpack/ruby_backtracer/tree/master
gem install ruby-debug # if you don’t have it installed

then run as ruby -rbacktracer script_name

Sorry it’s not a gem yet, should be by next week.
Feedback welcome.
Enjoy!
-=r