summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/client.rb28
-rw-r--r--lib/chef/config.rb1
-rw-r--r--lib/chef/exceptions.rb2
3 files changed, 22 insertions, 9 deletions
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 0764d3f3ba..bf99f003fb 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -336,7 +336,7 @@ class Chef
@events.converge_start(run_context)
Chef::Log.debug("Converging node #{node_name}")
@runner = Chef::Runner.new(run_context)
- runner.converge
+ @runner.converge
@events.converge_complete
rescue Exception => e
@events.converge_failed(e)
@@ -370,9 +370,11 @@ class Chef
auditor = Chef::Audit::Runner.new(run_context)
auditor.run
if auditor.failed?
- raise Chef::Exceptions::AuditsFailed.new(auditor.num_failed, auditor.num_total)
+ audit_exception = Chef::Exceptions::AuditsFailed.new(auditor.num_failed, auditor.num_total)
+ @events.audit_phase_failed(audit_exception)
+ else
+ @events.audit_phase_complete
end
- @events.audit_phase_complete
rescue Exception => e
Chef::Log.error("Audit phase failed with error message: #{e.message}")
@events.audit_phase_failed(e)
@@ -464,10 +466,9 @@ class Chef
audit_error = run_audits(run_context)
end
- if converge_error || audit_error
- e = Chef::Exceptions::RunFailedWrappingError.new(converge_error, audit_error)
- e.fill_backtrace
- raise e
+ if err = wrap_exceptions(converge_error, audit_error)
+ err.fill_backtrace
+ raise err
end
run_status.stop_clock
@@ -537,6 +538,19 @@ class Chef
Chef::ReservedNames::Win32::Security.has_admin_privileges?
end
+ def wrap_exceptions(converge_error, audit_error)
+ if audit_error && !(audit_error.is_a?(Chef::Exceptions::AuditsFailed) && Chef::Config[:audit_as_warning])
+ if converge_error
+ return Chef::Exceptions::RunFailedWrappingError.new(converge_error, audit_error)
+ else
+ return Chef::Exceptions::RunFailedWrappingError.new(audit_error)
+ end
+ elsif converge_error
+ return Chef::Exceptions::RunFailedWrappingError.new(converge_error)
+ end
+ nil
+ end
+
end
end
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index 629553c8ab..9beb18b53e 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -51,4 +51,3 @@ class Chef
end
end
-
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index da562e70f4..c0f4158db4 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -435,7 +435,7 @@ class Chef
wrapped_errors.each_with_index do |e,i|
backtrace << "#{i+1}) #{e.class} - #{e.message}"
backtrace += e.backtrace if e.backtrace
- backtrace << ""
+ backtrace << "" unless i == wrapped_errors.length - 1
end
set_backtrace(backtrace)
end