1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #2689: add error handling (#4294)

This commit is contained in:
Alejandro Huertas Herrero 2020-03-03 12:55:41 +01:00 committed by GitHub
parent f2d87cd988
commit 459e287ff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -453,7 +453,7 @@ module CommandParser
if comm.nil?
print_help
exit -1
exit 0
end
if comm[:deprecated]
@ -464,16 +464,27 @@ module CommandParser
parse(extra_options)
if comm
@before_proc.call if @before_proc
begin
@before_proc.call if @before_proc
rescue StandardError => e
STDERR.puts e.message
exit(-1)
end
check_args!(comm_name, comm[:arity], comm[:args_format])
rc = comm[:proc].call
if rc.instance_of?(Array)
puts rc[1]
exit rc.first
else
exit(@exit_code || rc)
begin
rc = comm[:proc].call
if rc.instance_of?(Array)
puts rc[1]
exit rc.first
else
exit(@exit_code || rc)
end
rescue StandardError => e
STDERR.puts e.message
exit(-1)
end
end
end
@ -501,10 +512,10 @@ module CommandParser
with_proc<<e
elsif e[:name]=="help"
print_help
exit
exit 0
elsif e[:name]=="version"
puts @version
exit
exit 0
elsif !e[:multiple]
@options[e[:name].to_sym]=o
else