diff options
author | Andre Arko <andre@arko.net> | 2013-02-14 23:12:01 -0800 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2013-02-17 00:23:46 -0800 |
commit | 3ae71e4c3d30b250924daf5765e81650d779690f (patch) | |
tree | ff9a8d403224affb8da2675302f803bfca537c9e /lib/bundler/fetcher.rb | |
parent | 18db5b8fad6489b81b2b118791632ec0ed257846 (diff) | |
download | bundler-3ae71e4c3d30b250924daf5765e81650d779690f.tar.gz |
wow my idea of exception internals was wrong
Diffstat (limited to 'lib/bundler/fetcher.rb')
-rw-r--r-- | lib/bundler/fetcher.rb | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index deb1cbdbe1..3f070ce041 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -1,24 +1,27 @@ require 'bundler/vendored_persistent' module Bundler - # This is the error raised if OpenSSL fails the cert verification - class CertificateFailureError < HTTPError - def initialize(message = nil) - @message = message - @message ||= "\nCould not verify the SSL certificate for " \ - "#{@remote_uri}. Either you don't have the CA certificates needed to " \ - "verify it, or you are experiencing a man-in-the-middle attack. To " \ - "connect without using SSL, edit your Gemfile sources to and change " \ - "'https' to 'http'." - end - end # Handles all the fetching with the rubygems server class Fetcher + # How many redirects to allew in one request REDIRECT_LIMIT = 5 # how long to wait for each gemcutter API call - API_TIMEOUT = 10 - class FallbackError < Bundler::HTTPError; end + API_TIMEOUT = 10 + + # This error is raised if the API returns a 413 (only printed in verbose) + class FallbackError < HTTPError; end + # This is the error raised if OpenSSL fails the cert verification + class CertificateFailureError < HTTPError + def initialize(remote_uri) + super "Could not verify the SSL certificate for #{remote_uri}.\nThere" \ + " is a chance you are experiencing a man-in-the-middle attack, but" \ + " most likely your system doesn't have the CA certificates needed" \ + " for verification. For information about OpenSSL certificates, see" \ + " bit.ly/ssl-certs. To connect without using SSL, edit your Gemfile" \ + " sources and change 'https' to 'http'." + end + end class << self attr_accessor :disable_endpoint @@ -107,7 +110,8 @@ module Bundler index rescue OpenSSL::SSL::SSLError - raise CertificateFailureError.new + Bundler.ui.info "" if gem_names && use_api # newline after dots + raise CertificateFailureError.new(@public_uri) end # fetch index @@ -239,7 +243,7 @@ module Bundler Bundler.rubygems.fetch_all_remote_specs rescue Gem::RemoteFetcher::FetchError => e if e.message.match("certificate verify failed") - raise CertificateFailureError.new + raise CertificateFailureError.new(@public_uri) else raise HTTPError, "Could not fetch specs from #{@public_uri}" end |