diff options
author | tyler-ball <tyleraball@gmail.com> | 2014-10-30 20:44:36 -0700 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-12-17 18:47:25 -0800 |
commit | 66665a7f699a592b77249a31af229f1412d90458 (patch) | |
tree | 4a506eb58a772aba0047bae3c479ee1d11879b47 /lib/chef/exceptions.rb | |
parent | 4cfb1e47aa8e9501f4f2a01f1d8cc0deb2cfa13b (diff) | |
download | chef-66665a7f699a592b77249a31af229f1412d90458.tar.gz |
Adding logic for exceptions from converge phase not interfering with audit phase and vice-versa
Diffstat (limited to 'lib/chef/exceptions.rb')
-rw-r--r-- | lib/chef/exceptions.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index 55d6fcc893..179a1fa27e 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -386,5 +386,27 @@ class Chef end class NoAuditsProvided < RuntimeError; end + + # If a converge or audit fails, we want to wrap the output from those errors into 1 error so we can + # see both issues in the output. It is possible that nil will be provided. You must call `fill_backtrace` + # to correctly populate the backtrace with the wrapped backtraces. + class RunFailedWrappingError < RuntimeError + attr_reader :wrapped_errors + def initialize(*errors) + errors = errors.select {|e| !e.nil?} + output = "Found #{errors.size} errors, they are stored in the backtrace\n" + @wrapped_errors = errors + super output + end + + def fill_backtrace + backtrace = [] + wrapped_errors.each_with_index do |e,i| + backtrace << "#{i+1}) #{e.message}" + backtrace += e.backtrace + backtrace << "" + end + end + end end end |