Skip to content

Commit

Permalink
Rescue all exceptions and try to be a bit more helpful when they occur.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Sep 13, 2011
1 parent d750675 commit bdb96b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/pod
Expand Up @@ -7,4 +7,4 @@ end

require 'cocoa_pods'

Pod::Command.parse(*ARGV).run
Pod::Command.run(*ARGV)
33 changes: 23 additions & 10 deletions lib/cocoa_pods/command.rb
Expand Up @@ -10,13 +10,15 @@ def initialize(command_class, argv)
@command_class, @argv = command_class, argv
end

def run
puts @command_class.banner
puts
puts "Options"
puts "-------"
puts
puts @command_class.options
def message
[
@command_class.banner,
'',
'Options',
'-------',
'',
@command_class.options
].join("\n")
end
end

Expand All @@ -41,6 +43,19 @@ def self.options
" --verbose Print more information while working"
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)
argv = ARGV.new(argv)
show_help = argv.option('--help')
Expand All @@ -54,12 +69,10 @@ def self.parse(*argv)
end

if show_help || command_class.nil?
Help.new(command_class || self, argv)
raise Help.new(command_class || self, argv)
else
command_class.new(argv)
end
rescue Help => help
return help
end

include Config::Mixin
Expand Down

0 comments on commit bdb96b1

Please sign in to comment.