Skip to content

A platform for community discussion. Free, open, simple.

Include response body when raising an error in `FileHelper#download`.

Guo Xiang Tan6c657183012e
diff --git a/lib/file_helper.rb b/lib/file_helper.rb
index f7d2a0907d8..f146b8b139d 100644
--- a/lib/file_helper.rb
+++ b/lib/file_helper.rb
@@ -48,7 +48,7 @@ class FileHelper
# attempt error API compatibility
io = FakeIO.new
io.status = [response.code, ""]
- raise OpenURI::HTTPError.new("#{response.code} Error", io)
+ raise OpenURI::HTTPError.new("#{response.code} Error: #{response.body}", io)
else
log(:error, "FinalDestination did not work for: #{url}") if verbose
throw :done
diff --git a/spec/components/file_helper_spec.rb b/spec/components/file_helper_spec.rb
index ec81a94b575..6baa22ccff1 100644
--- a/spec/components/file_helper_spec.rb
+++ b/spec/components/file_helper_spec.rb
@@ -28,7 +28,7 @@ describe FileHelper do
expect(e.io.status[0]).to eq("404")
raise
end
- end.to raise_error(OpenURI::HTTPError)
+ end.to raise_error(OpenURI::HTTPError, "404 Error: 404")
end
it "correctly raises an OpenURI HTTP error if it gets a 404" do