Show command when remote execution fail
This commit is contained in:
@@ -5,18 +5,22 @@ module Producer
|
||||
|
||||
USAGE = "Usage: #{File.basename $0} [-v] [-n] recipe_file".freeze
|
||||
|
||||
EX_USAGE = 64
|
||||
EX_USAGE = 64
|
||||
EX_SOFTWARE = 70
|
||||
|
||||
class << self
|
||||
def run!(arguments, output: $stderr)
|
||||
cli = new(arguments)
|
||||
begin
|
||||
cli = new(arguments)
|
||||
cli.parse_arguments!
|
||||
cli.run
|
||||
rescue ArgumentError
|
||||
output.puts USAGE
|
||||
exit EX_USAGE
|
||||
rescue RuntimeError => e
|
||||
output.puts "#{e.class.name.split('::').last}: #{e.message}"
|
||||
exit EX_SOFTWARE
|
||||
end
|
||||
cli.run
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
module Producer
|
||||
module Core
|
||||
Error = Class.new(StandardError)
|
||||
RuntimeError = Class.new(RuntimeError)
|
||||
ConditionNotMetError = Class.new(Error)
|
||||
RemoteCommandExecutionError = Class.new(Error)
|
||||
RemoteCommandExecutionError = Class.new(RuntimeError)
|
||||
end
|
||||
end
|
||||
|
@@ -32,7 +32,7 @@ module Producer
|
||||
|
||||
ch.on_request 'exit-status' do |c, data|
|
||||
exit_status = data.read_long
|
||||
raise RemoteCommandExecutionError if exit_status != 0
|
||||
raise RemoteCommandExecutionError, command if exit_status != 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user