Handle SocketError. #359

This commit is contained in:
Steve Bazyl 2016-02-25 13:30:27 -08:00
parent e67964189e
commit 07ca6e8ca0
2 changed files with 7 additions and 1 deletions

View File

@ -251,7 +251,7 @@ module Google
# @raise [StandardError] if no block
def error(err, rethrow: false, &block)
logger.debug { sprintf('Error - %s', PP.pp(err, '')) }
err = Google::Apis::TransmissionError.new(err) if err.is_a?(Hurley::ClientError)
err = Google::Apis::TransmissionError.new(err) if err.is_a?(Hurley::ClientError) || err.is_a?(SocketError)
block.call(nil, err) if block_given?
fail err if rethrow || block.nil?
end

View File

@ -294,4 +294,10 @@ RSpec.describe Google::Apis::Core::HttpCommand do
command.execute(client)
end
it 'should raise transmission error instead of socket error' do
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_raise(SocketError)
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
end