def self.with_friendly_errors
yield
rescue Bundler::YamlSyntaxError => e
Bundler.ui.error e.message
Bundler.ui.trace e.orig_exception
exit e.status_code
rescue Bundler::Dsl::DSLError => e
Bundler.ui.error e.message
exit e.status_code
rescue Bundler::GemRequireError => e
Bundler.ui.error e.message
Bundler.ui.trace e.orig_exception, nil, true
exit e.status_code
rescue Bundler::BundlerError => e
Bundler.ui.error e.message, :wrap => true
Bundler.ui.trace e
exit e.status_code
rescue Thor::AmbiguousTaskError => e
Bundler.ui.error e.message
exit 15
rescue Thor::UndefinedTaskError => e
Bundler.ui.error e.message
exit 15
rescue Thor::Error => e
Bundler.ui.error e.message
exit 1
rescue LoadError => e
raise e unless e.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 \\\nGemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \\\nusing RVM are available at http://rvm.io/packages/openssl.\n", :wrap => true
Bundler.ui.trace e
exit 1
rescue Interrupt => e
Bundler.ui.error "\nQuitting..."
Bundler.ui.trace e
exit 1
rescue SystemExit => e
exit e.status
rescue Exception => e
request_issue_report_for(e)
exit 1
end