Commit bdb96b1c authored by Eloy Duran's avatar Eloy Duran

Rescue all exceptions and try to be a bit more helpful when they occur.

parent d7506754
...@@ -7,4 +7,4 @@ end ...@@ -7,4 +7,4 @@ end
require 'cocoa_pods' require 'cocoa_pods'
Pod::Command.parse(*ARGV).run Pod::Command.run(*ARGV)
...@@ -10,13 +10,15 @@ module Pod ...@@ -10,13 +10,15 @@ module Pod
@command_class, @argv = command_class, argv @command_class, @argv = command_class, argv
end end
def run def message
puts @command_class.banner [
puts @command_class.banner,
puts "Options" '',
puts "-------" 'Options',
puts '-------',
puts @command_class.options '',
@command_class.options
].join("\n")
end end
end end
...@@ -41,6 +43,19 @@ module Pod ...@@ -41,6 +43,19 @@ module Pod
" --verbose Print more information while working" " --verbose Print more information while working"
end end
def self.run(*argv)
parse(*argv).run
rescue Exception => e
unless e.is_a?(Help)
puts "Oh no, an error occurred. Please run with `--verbose' and report " \
"on https://github.com/alloy/cocoa-pods/issues."
puts ""
end
puts e.message
puts *e.backtrace if Config.instance.verbose
exit 1
end
def self.parse(*argv) def self.parse(*argv)
argv = ARGV.new(argv) argv = ARGV.new(argv)
show_help = argv.option('--help') show_help = argv.option('--help')
...@@ -54,12 +69,10 @@ module Pod ...@@ -54,12 +69,10 @@ module Pod
end end
if show_help || command_class.nil? if show_help || command_class.nil?
Help.new(command_class || self, argv) raise Help.new(command_class || self, argv)
else else
command_class.new(argv) command_class.new(argv)
end end
rescue Help => help
return help
end end
include Config::Mixin include Config::Mixin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment