Method: Puppet::Util::Errors#exceptwrap
- Defined in:
- lib/puppet/util/errors.rb
#exceptwrap(options = {}) ⇒ Object
Wrap a call in such a way that we always throw the right exception and keep as much context as possible.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/puppet/util/errors.rb', line 112 def exceptwrap( = {}) [:type] ||= Puppet::DevError begin return yield rescue Puppet::Error => detail raise adderrorcontext(detail) rescue => detail = [:message] || _("%{klass} failed with error %{error_type}: %{detail}") % { klass: self.class, error_type: detail.class, detail: detail } error = [:type].new() # We can't use self.fail here because it always expects strings, # not exceptions. raise adderrorcontext(error, detail) end retval end |