Skip to content

Commit

Permalink
Handle net http open timeout error.
Browse files Browse the repository at this point in the history
  • Loading branch information
mistersourcerer committed Oct 5, 2017
1 parent 8c4b5e0 commit d1bbabf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/faraday/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def call(env)
begin
http_response = perform_request(http, env)
rescue *NET_HTTP_EXCEPTIONS => err
if defined?(OpenSSL) && OpenSSL::SSL::SSLError === err
if defined?(Net::OpenTimeout) && err.is_a?(Net::OpenTimeout)
raise Faraday::Error::OpenTimeoutError, err
elsif defined?(OpenSSL) && OpenSSL::SSL::SSLError === err
raise Faraday::SSLError, err
else
raise Error::ConnectionFailed, err
Expand Down

1 comment on commit d1bbabf

@coberlin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this will be backwards compatible since OpenTimeoutError inherits from TimeoutError, not ConnectionFailed. See @iMacTia's comment.

Since OpenTimeoutError needs to inherit from TimeoutError for HTTPClient, consider another error (OpenConnectionError?) that inherits from ConnectionFailed.

Please sign in to comment.