Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Print a template for a new ticket when an error occurs. See #163.

  • Loading branch information...
commit a08e913ada5bef58196c77899f4d153b2fba03ca 1 parent 22f77e4
@alloy alloy authored
View
24 lib/cocoapods/command.rb
@@ -1,11 +1,12 @@
module Pod
class Command
- autoload :Install, 'cocoapods/command/install'
- autoload :Repo, 'cocoapods/command/repo'
- autoload :Search, 'cocoapods/command/search'
- autoload :List, 'cocoapods/command/list'
- autoload :Setup, 'cocoapods/command/setup'
- autoload :Spec, 'cocoapods/command/spec'
+ autoload :ErrorReport, 'cocoapods/command/error_report'
+ autoload :Install, 'cocoapods/command/install'
+ autoload :List, 'cocoapods/command/list'
+ autoload :Repo, 'cocoapods/command/repo'
+ autoload :Search, 'cocoapods/command/search'
+ autoload :Setup, 'cocoapods/command/setup'
+ autoload :Spec, 'cocoapods/command/spec'
class Help < Informative
def initialize(command_class, argv)
@@ -52,13 +53,12 @@ def self.options
def self.run(*argv)
parse(*argv).run
rescue Exception => e
- unless e.is_a?(Informative)
- puts "Oh no, an error occurred. Please run with `--verbose' and report " \
- "on https://github.com/CocoaPods/CocoaPods/issues."
- puts ""
+ if e.is_a?(Informative)
+ puts e.message
+ puts *e.backtrace if Config.instance.verbose
+ else
+ puts ErrorReport.report(e)
end
- puts e.message
- puts *e.backtrace if Config.instance.verbose
exit 1
end
View
82 lib/cocoapods/command/error_report.rb
@@ -0,0 +1,82 @@
+require 'rbconfig'
+require 'cgi'
+
+module Pod
+ class Command
+ module ErrorReport
+ class << self
+ def report(error)
+ return <<-EOS
+Oh no, an error occurred. #{error_from_podfile(error)}
+
+Search for existing github issues similar to yours:
+
+ https://github.com/CocoaPods/CocoaPods/issues/search?q=%22#{CGI.escape(error.message)}%22
+
+If none exists, create a ticket with the following information to:
+
+ https://github.com/CocoaPods/CocoaPods/issues/new
+
+Don't forget to anonymize any private data!
+
+
+### Stack
+
+* Host version: #{host_information}
+* Xcode version: #{xcode_information}
+* Ruby version: #{RUBY_DESCRIPTION}
+* Ruby lib dir: #{RbConfig::CONFIG['libdir']}
+* RubyGems version: #{Gem::VERSION}
+* CocoaPods version: #{Pod::VERSION}
+* Specification repositories:
+ - #{repo_information.join("\n - ")}
+
+
+### Podfile
+
+```ruby
+#{Config.instance.project_podfile.read}
+```
+
+
+### Error
+
+```
+#{error.message}
+ #{error.backtrace.join("\n ")}
+```
+EOS
+ end
+
+ private
+
+ def error_from_podfile(error)
+ if error.message =~ /Podfile:(\d*)/
+ "It appears to have originated from your Podfile at line #{$1}."
+ end
+ end
+
+ def host_information
+ product, version, build =`sw_vers`.strip.split("\n").map { |line| line.split(":").last.strip }
+ "#{product} #{version} (#{build})"
+ end
+
+ def xcode_information
+ version, build = `xcodebuild -version`.strip.split("\n").map { |line| line.split(" ").last }
+ "#{version} (#{build})"
+ end
+
+ def repo_information
+ Pod::Source.all.map do |source|
+ repo = source.repo
+ Dir.chdir(repo) do
+ url = `git config --get remote.origin.url`.strip
+ sha = `git rev-parse HEAD`.strip
+ "#{repo.basename} - #{url} @ #{sha}"
+ end
+ end
+ end
+ end
+ end
+ end
+end
View
1  lib/cocoapods/config.rb
@@ -33,6 +33,7 @@ def project_pods_root
def project_podfile
unless @project_podfile
@project_podfile = project_root + 'Podfile'
+ # TODO this has to go, we don't support this anymore!
unless @project_podfile.exist?
@project_podfile = project_root.glob('*.podspec').first
end
Please sign in to comment.
Something went wrong with that request. Please try again.