Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

[Downloader] Print underlying error in HTTPError #5579

Merged
merged 1 commit into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/bundler/fetcher/downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ def request(uri, options)
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."
"connection and try again."
else
raise HTTPError, "Network error while fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
raise HTTPError, "Network error while fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" \
" (#{e})"
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/bundler/fetcher/downloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@

it "should raise a Bundler::HTTPError" do
expect { subject.request(uri, options) }.to raise_error(Bundler::HTTPError,
"Network error while fetching http://www.uri-to-fetch.com/api/v2/endpoint")
"Network error while fetching http://www.uri-to-fetch.com/api/v2/endpoint (other error about network)")
end

context "when the there are credentials provided in the request" do
Expand All @@ -233,7 +233,7 @@

it "should raise a Bundler::HTTPError that doesn't contain the password" do
expect { subject.request(uri, options) }.to raise_error(Bundler::HTTPError,
"Network error while fetching http://username@www.uri-to-fetch.com/api/v2/endpoint")
"Network error while fetching http://username@www.uri-to-fetch.com/api/v2/endpoint (other error about network)")
end
end
end
Expand All @@ -243,7 +243,7 @@

it "should raise a Bundler::Fetcher::HTTPError" do
expect { subject.request(uri, options) }.to raise_error(Bundler::HTTPError,
"Network error while fetching http://www.uri-to-fetch.com/api/v2/endpoint")
"Network error while fetching http://www.uri-to-fetch.com/api/v2/endpoint (#{message})")
end
end
end
Expand Down