Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit bdb96b1cd58d163ca675a4127171b3108970f81b 1 parent d750675
@alloy alloy authored
Showing with 24 additions and 11 deletions.
  1. +1 −1  bin/pod
  2. +23 −10 lib/cocoa_pods/command.rb
View
2  bin/pod
@@ -7,4 +7,4 @@ end
require 'cocoa_pods'
-Pod::Command.parse(*ARGV).run
+Pod::Command.run(*ARGV)
View
33 lib/cocoa_pods/command.rb
@@ -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
@@ -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')
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.