puppetlabs/puppet — pull request #2293 by Iristyle (2014-01-23 23:03:10+00:00)
Title: (maint) Puppet fails to properly surface backtraces

- In many cases, exceptions are handled with Ruby and rethrown in
a manner that loses the original exceptions backtrace. This often
masks the real backtrace associated with an error, and can be the
source of misleading errors or fishing expeditions.
- Where appropriate, pass along the backtrace, or use the initializer
of the raised Error to wrap / extract the backtrace from the existing
exception.
- Puppet::Util::Windows::Error is given a new initializer that allows
passing in the original Exception
- Puppet::Util::Errors.fail adds a new overload that allows for the
original Exception to be passed in
- To summarize, calls structured like this preserve backtraces:
rescue ArgumentError => e
raise
raise e, e.message, e.backtrace
raise e
rescue
raise
raise $!
raise $!, "bad arg yo -- part 2", $!.backtrace
raise $!, $!.message, $!.backtrace
raise Puppet::Error.new("new msg / ex type", detail)
- To summarize, calls structured like this will eat backtraces:
rescue
raise $!, "Just smoked the backtrace on existing exception"
raise "Just smoked the backtrace and changed to RuntimeError"
raise RuntimeError.new($!)