diff options
author | Bryan McLellan <btm@loftninjas.org> | 2012-08-10 13:53:59 -0400 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2012-08-10 13:57:24 -0400 |
commit | 3a09e77554c87fbda0c36eb2cb19875aa1522e51 (patch) | |
tree | 4429a3b96373ec85afe23eac79383f8a3d1e9456 | |
parent | 0eeeca950dfb8342ff30fa375fc7967a682fcbba (diff) | |
download | chef-3a09e77554c87fbda0c36eb2cb19875aa1522e51.tar.gz |
CHEF-3336: Raise exceptions correctly when they happen early
Exceptions could be raised before run_status is set, so make sure that we
don't swallow them.
-rw-r--r-- | chef/lib/chef/client.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/chef/lib/chef/client.rb b/chef/lib/chef/client.rb index 8f57cdd5a0..bd0c0548a2 100644 --- a/chef/lib/chef/client.rb +++ b/chef/lib/chef/client.rb @@ -427,10 +427,14 @@ class Chef @events.run_completed(node) true rescue Exception => e - run_status.stop_clock - run_status.exception = e - run_failed + # CHEF-3336: Send the error first in case something goes wrong below and we don't know why Chef::Log.debug("Re-raising exception: #{e.class} - #{e.message}\n#{e.backtrace.join("\n ")}") + # If we failed really early, we may not have a run_status yet. Too early for these to be of much use. + if run_status + run_status.stop_clock + run_status.exception = e + run_failed + end @events.run_failed(e) raise ensure |