lib/perus/pinger/command.rb in perus-0.1.6 vs lib/perus/pinger/command.rb in perus-0.1.7

- old
+ new

@@ -124,11 +124,18 @@ # helper function to run shell commands and return early if anything # is written to stderr or the command didn't run successfully class ShellCommandError < StandardError; end def shell(command) out, err, status = Open3.capture3(command) - raise ShellCommandError.new(err.strip) unless err.empty? - raise ShellCommandError.new(out.strip) if status.exitstatus > 0 + + unless err.empty? + raise ShellCommandError.new(err.strip) + end + + if status.exitstatus > 0 + raise ShellCommandError.new("#{out.strip}; exit: #{status.exitstatus}") + end + out end def darwin? shell('uname -s').strip == 'Darwin'