Wrap Errno::ETIMEDOUT in Faraday::Error::TimeoutError

Closes #324
This commit is contained in:
Ricardo Valeriano 2015-03-30 12:44:04 -03:00 committed by Mislav Marohnić
parent c94890c499
commit f73d13ee09
4 changed files with 6 additions and 2 deletions

View File

@ -70,6 +70,8 @@ module Faraday
else
raise Error::ConnectionFailed, err
end
rescue Errno::ETIMEDOUT => err
raise Error::TimeoutError, err
rescue RuntimeError => err
if err.message == "connection closed by server"
raise Error::ConnectionFailed, err

View File

@ -40,7 +40,7 @@ module Faraday
save_response env, resp.status, resp.body, resp.headers
@app.call env
rescue ::HTTPClient::TimeoutError
rescue ::HTTPClient::TimeoutError, Errno::ETIMEDOUT
raise Faraday::Error::TimeoutError, $!
rescue ::HTTPClient::BadResponseError => err
if err.message.include?('status 407')

View File

@ -54,7 +54,7 @@ module Faraday
end
@app.call env
rescue Timeout::Error => err
rescue Timeout::Error, Errno::ETIMEDOUT => err
raise Faraday::Error::TimeoutError, err
end

View File

@ -23,6 +23,8 @@ module Faraday
def perform_request(http, env)
http.request env[:url], create_request(env)
rescue Errno::ETIMEDOUT => error
raise Faraday::Error::TimeoutError, error
rescue Net::HTTP::Persistent::Error => error
if error.message.include? 'Timeout'
raise Faraday::Error::TimeoutError, error