diff --git a/google-apis-core/lib/google/apis/core/http_command.rb b/google-apis-core/lib/google/apis/core/http_command.rb index 70ce4249fe5..ab2a0b5087d 100644 --- a/google-apis-core/lib/google/apis/core/http_command.rb +++ b/google-apis-core/lib/google/apis/core/http_command.rb @@ -292,7 +292,12 @@ def error(err, rethrow: false, &block) rescue Google::Apis::Error => e err = e end - elsif err.is_a?(HTTPClient::TimeoutError) || err.is_a?(SocketError) || err.is_a?(HTTPClient::KeepAliveDisconnected) || err.is_a?(Errno::ECONNREFUSED) || err.is_a?(Errno::ETIMEDOUT) + elsif err.is_a?(HTTPClient::TimeoutError) || + err.is_a?(SocketError) || + err.is_a?(HTTPClient::KeepAliveDisconnected) || + err.is_a?(Errno::ECONNREFUSED) || + err.is_a?(Errno::ETIMEDOUT) || + err.is_a?(Errno::ECONNRESET) err = Google::Apis::TransmissionError.new(err) end block.call(nil, err) if block_given? diff --git a/google-apis-core/spec/google/apis/core/http_command_spec.rb b/google-apis-core/spec/google/apis/core/http_command_spec.rb index 55ddaf4652a..7d865e2f4e9 100644 --- a/google-apis-core/spec/google/apis/core/http_command_spec.rb +++ b/google-apis-core/spec/google/apis/core/http_command_spec.rb @@ -495,6 +495,13 @@ class SecretPayload expect { command.execute(client) }.to raise_error(Google::Apis::TransmissionError) end + it 'should raise transmission error for broken network connection' do + stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_raise(Errno::ECONNRESET) + command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals') + command.options.retries = 0 + expect { command.execute(client) }.to raise_error(Google::Apis::TransmissionError) + end + it 'should raise rate limit error for 429 status codes' do stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(status: [429, '']) command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')