Module: Bundler::FriendlyErrors

Defined in:
lib/bundler/friendly_errors.rb

Class Method Summary collapse

Class Method Details

.exit_status(error) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/bundler/friendly_errors.rb', line 44

def exit_status(error)
  case error
  when BundlerError then error.status_code
  when Thor::Error then 15
  when SystemExit then error.status
  else 1
  end
end

.issues_url(exception) ⇒ Object



91
92
93
94
# File 'lib/bundler/friendly_errors.rb', line 91

def issues_url(exception)
  "https://github.com/bundler/bundler/search?q=" \
    "#{CGI.escape(exception.message.lines.first.chomp)}&type=Issues"
end

.log_error(error) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bundler/friendly_errors.rb', line 10

def log_error(error)
  case error
  when YamlSyntaxError
    Bundler.ui.error error.message
    Bundler.ui.trace error.orig_exception
  when Dsl::DSLError
    Bundler.ui.error error.message
  when GemRequireError
    Bundler.ui.error error.message
    Bundler.ui.trace error.orig_exception, nil, true
  when BundlerError
    Bundler.ui.error error.message, :wrap => true
    Bundler.ui.trace error
  when Thor::Error
    Bundler.ui.error error.message
  when LoadError
    raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
    Bundler.ui.error "\nCould not load OpenSSL."
    Bundler.ui.warn "      You must recompile Ruby with OpenSSL support or change the sources in your \\\n      Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \\\n      using RVM are available at http://rvm.io/packages/openssl.\n    WARN\n    Bundler.ui.trace error\n  when Interrupt\n    Bundler.ui.error \"\\nQuitting...\"\n    Bundler.ui.trace error\n  when Gem::InvalidSpecificationException\n    Bundler.ui.error error.message, :wrap => true\n  when SystemExit\n  else request_issue_report_for(error)\n  end\nend\n", :wrap => true

.request_issue_report_for(e) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/bundler/friendly_errors.rb', line 53

def request_issue_report_for(e)
  Bundler.ui.info "    --- ERROR REPORT TEMPLATE -------------------------------------------------------\n    - What did you do?\n\n      I ran the command `\#{$PROGRAM_NAME} \#{ARGV.join(\" \")}`\n\n    - What did you expect to happen?\n\n      I expected Bundler to...\n\n    - What happened instead?\n\n      Instead, what actually happened was...\n\n\n    Error details\n\n        \#{e.class}: \#{e.message}\n          \#{e.backtrace.join(\"\\n              \")}\n\n    \#{Bundler::Env.new.report(:print_gemfile => false, :print_gemspecs => false).gsub(/\\n/, \"\\n      \").strip}\n    --- TEMPLATE END ----------------------------------------------------------------\n\n  EOS\n\n  Bundler.ui.error \"Unfortunately, an unexpected error occurred, and Bundler cannot continue.\"\n\n  Bundler.ui.warn <<-EOS.gsub(/^ {8}/, \"\")\n\n    First, try this link to see if there are any existing issue reports for this error:\n    \#{issues_url(e)}\n\n    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:\n    https://github.com/bundler/bundler/issues/new\n  EOS\nend\n".gsub(/^ {8}/, "")