Consider the following ruby code
test.rb:
begin puts thisFunctionDoesNotExist x = 1+1 rescue Exception => e p e end
For deb
Throwing my $0.02 in on this old thread-- here's a simple solution that maintains all the original data:
print e.backtrace.join("\n")