summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2014-08-25 20:38:26 -0700
committerAndre Arko <andre@arko.net>2014-08-25 20:54:05 -0700
commit99ab5b01795da5c0f841790d31c4e8f907d0cb66 (patch)
treee14ae02d4145b495472806595332fdb613433b47
parent0898511a4ea8380a57646a2bd3b7c4bc749c3fd3 (diff)
downloadbundler-99ab5b01795da5c0f841790d31c4e8f907d0cb66.tar.gz
Second try at failing immediately with no network
-rw-r--r--lib/bundler/fetcher.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index 4ab2bc67b5..8c8f3172ef 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -6,6 +6,8 @@ module Bundler
# Handles all the fetching with the rubygems server
class Fetcher
+ # This error is raised when it looks like the network is down
+ class NetworkDownError < HTTPError; end
# 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
@@ -166,7 +168,6 @@ module Bundler
index = Index.new
if gem_names && use_api
- fetch(dependency_api_uri)
specs = fetch_remote_specs(gem_names)
end
@@ -193,7 +194,7 @@ module Bundler
end
index
- rescue CertificateFailureError, HTTPError => e
+ rescue CertificateFailureError => e
Bundler.ui.info "" if gem_names && use_api # newline after dots
raise e
ensure
@@ -232,9 +233,13 @@ module Bundler
if @remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
@use_api = false
- else
+ elsif fetch(dependency_api_uri)
@use_api = true
end
+ rescue NetworkDownError => e
+ raise HTTPError, e.message
+ rescue HTTPError
+ @use_api = false
end
def inspect
@@ -298,9 +303,10 @@ module Bundler
raise CertificateFailureError.new(uri)
rescue *HTTP_ERRORS => e
Bundler.ui.trace e
- if e.message == "getaddrinfo: nodename nor servname provided, or not known"
- raise HTTPError, "Could not reach host #{uri.host}. Check your network " \
- "connection and try again."
+ case e.message
+ when /host down:/, /getaddrinfo: nodename nor servname provided/
+ raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
+ "connection and try again."
else
raise HTTPError, "Network error while fetching #{uri}"
end