Handle bad response errors without response object (#765)

We have received word that a bad proxy setting can cause this behavior.

[fixes #764]
This commit is contained in:
Mike Moore authored and GitHub committed 2019-02-14 14:14:34 -07:00
1 parent 06a01959cf
commit 6e90789b27
2 files changed
+27

No files matched your search

@@ -197,6 +197,32 @@ RSpec.describe Google::Apis::Core::HttpCommand do
end
end
context('with unknown errors') do
let(:command) do
Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
end
before(:example) do
stub_request(:get, 'https://www.googleapis.com/zoo/animals')
.to_raise(HTTPClient::BadResponseError) # empty error, no res value
end
it 'should raise transmission error' do
command.options.retries = 1
err = nil
begin
command.execute(client)
rescue Google::Apis::Error => e
err = e
end
expect(err).to be_a(Google::Apis::TransmissionError)
expect(err.cause).to be_a(HTTPClient::BadResponseError)
expect(err.cause.res).to be_nil # no res value
end
end
context('with options') do
let(:command) do
command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')