Handle SocketError. #359
This commit is contained in:
parent
e67964189e
commit
07ca6e8ca0
|
@ -251,7 +251,7 @@ module Google
|
||||||
# @raise [StandardError] if no block
|
# @raise [StandardError] if no block
|
||||||
def error(err, rethrow: false, &block)
|
def error(err, rethrow: false, &block)
|
||||||
logger.debug { sprintf('Error - %s', PP.pp(err, '')) }
|
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?
|
block.call(nil, err) if block_given?
|
||||||
fail err if rethrow || block.nil?
|
fail err if rethrow || block.nil?
|
||||||
end
|
end
|
||||||
|
|
|
@ -294,4 +294,10 @@ RSpec.describe Google::Apis::Core::HttpCommand do
|
||||||
command.execute(client)
|
command.execute(client)
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue