summaryrefslogtreecommitdiff
path: root/lib/bundler/friendly_errors.rb
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2014-11-30 21:46:19 -0800
committerAndre Arko <andre@arko.net>2014-11-30 22:32:10 -0800
commitd0800d0033cd73ca08979c07827ffd232b18f97f (patch)
treec029d1726f65fd3dc5fcdc3a7bf2e65b9474c978 /lib/bundler/friendly_errors.rb
parent6a0ddc83e2cd0de7106c441e404fca418eca36dc (diff)
downloadbundler-d0800d0033cd73ca08979c07827ffd232b18f97f.tar.gz
indent error report template, extract method
Diffstat (limited to 'lib/bundler/friendly_errors.rb')
-rw-r--r--lib/bundler/friendly_errors.rb58
1 files changed, 26 insertions, 32 deletions
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 000d0d77bc..fde582c7f7 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -34,48 +34,42 @@ module Bundler
rescue SystemExit => e
exit e.status
rescue Exception => e
+ request_issue_report_for(e)
+ exit 1
+ end
- Bundler.ui.error <<-EOS
-#{'――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'}
-### Report
-* What did you do?
-* What did you expect to happen?
-* What happened instead?
+ def self.request_issue_report_for(e)
+ Bundler.ui.info <<-EOS.gsub(/^ {6}/, '')
+ #{'――― ERROR REPORT TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――'}
+ - What did you do?
+ - What did you expect to happen?
+ - What happened instead?
-#{Bundler::Env.new.report(:print_gemfile => false)}
+ Error details
-### Error
-```
-#{e.class} - #{e.message}
-#{e.backtrace.join("\n")}
-```
-#{'――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'}
-[!] Oh no, an error occurred.
+ #{e.class}: #{e.message}
+ #{e.backtrace.join("\n ")}
-Troubleshooting documentation: http://bit.ly/bundler-issues
+ #{Bundler::Env.new.report(:print_gemfile => false).gsub(/\n/, "\n ").strip}
+ #{'――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'}
-Search for existing github issues similar to yours:
-#{issues_url(e)}
+ EOS
-If none exists, create a ticket, with the template displayed above, on:
-https://github.com/bundler/bundler/issues/new
-Be sure to first read the contributing guide for details on how to properly submit a ticket:
-https://github.com/bundler/bundler/blob/master/CONTRIBUTING.md
-You may also include your Gemfile sample.
-Don't forget to anonymize any private data!
-EOS
- exit 1
+ Bundler.ui.error "Unfortunately, an unexpected error occurred, and Bundler cannot continue."
+
+ Bundler.ui.warn <<-EOS.gsub(/^ {6}/, '')
+
+ First, try this link to see if there are any existing issue reports for this error:
+ #{issues_url(e)}
+
+ If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
+ https://github.com/bundler/bundler/issues/new
+ EOS
end
def self.issues_url(exception)
- message = pathless_exception_message(exception.message)
'https://github.com/bundler/bundler/search?q=' \
- "#{CGI.escape(message)}&type=Issues"
- end
-
- def self.pathless_exception_message(message)
- message.gsub(/- \(.*\):/, '-')
+ "#{CGI.escape(exception.message)}&type=Issues"
end
-
end