Skip to content

Commit

Permalink
On error log STDOUT if STDERR is empty
Browse files Browse the repository at this point in the history
If a process doesn't correctly log to STDERR then the default .run! log
message isn't very helpful.  This logs command_result.error if it is
present, otherwise it logs command_result.output.
  • Loading branch information
agrare committed May 13, 2019
1 parent 7cbf922 commit 3e19868
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/awesome_spawn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def run!(command, options = {})

if command_result.failure?
message = CommandResultError.default_message(command, command_result.exit_status)
error_message = command_result.error.present? ? command_result.error : command_result.output

logger.error("AwesomeSpawn: #{message}")
logger.error("AwesomeSpawn: #{command_result.error}")
logger.error("AwesomeSpawn: #{error_message}")
raise CommandResultError.new(message, command_result)
end

Expand Down

0 comments on commit 3e19868

Please sign in to comment.