summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2016-02-11 11:22:52 -0800
committermcquin <claire@chef.io>2016-04-01 10:05:43 -0700
commit4cb6ed323642fb8b59d5d22eee0b4340b9c46cca (patch)
treee176572f0e8db2629bd24108045520dc050d72ac
parentadf7d64e4151aa00b627907d2b9ab3b3947fcdcf (diff)
downloadohai-4cb6ed323642fb8b59d5d22eee0b4340b9c46cca.tar.gz
Log non-0 exit codes and raise our own exception
-rw-r--r--lib/ohai/mixin/command.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb
index 0d9ae5a9..8cfc7d10 100644
--- a/lib/ohai/mixin/command.rb
+++ b/lib/ohai/mixin/command.rb
@@ -32,11 +32,17 @@ module Ohai
m = Mixlib::ShellOut.new(cmd)
begin
m.run_command
- Ohai::Log.debug("Plugin #{self.name} successfully ran command #{cmd}")
+
+ if m.exitstatus == 0
+ Ohai::Log.debug("Plugin #{self.name} successfully ran command #{cmd}")
+ else
+ Ohai::Log.debug("Plugin #{self.name} command #{cmd} returned status #{m.exitstatus}")
+ end
+
m
rescue Errno::ENOENT => e
Ohai::Log.debug("Plugin #{self.name} failed to run command #{cmd}")
- raise
+ raise Ohai::Exceptions::Exec, e
end
end