lib/perus/pinger/command.rb in perus-0.1.23 vs lib/perus/pinger/command.rb in perus-0.1.24
- old
+ new
@@ -125,15 +125,15 @@
# is written to stderr or the command didn't run successfully
class ShellCommandError < StandardError; end
def shell(command)
out, err, status = Open3.capture3(command)
- unless err.empty?
- raise ShellCommandError.new(err.strip)
+ if status.exitstatus > 0 && !err.empty?
+ raise ShellCommandError.new("(cmd: #{command}) => #{err.strip}; #{out.strip}; exit: #{status.exitstatus}")
end
if status.exitstatus > 0
- raise ShellCommandError.new("#{out.strip}; exit: #{status.exitstatus}")
+ raise ShellCommandError.new("(cmd: #{command}) => #{out.strip}; exit: #{status.exitstatus}")
end
out
end