Skip to content

Commit 35b12b3

Browse files
binarycodeioquatix
authored andcommitted
refactor timeout exception handling
1 parent 39ee771 commit 35b12b3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/async/http/faraday/adapter.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class Adapter < ::Faraday::Adapter
4141
IOError,
4242
SocketError
4343
].freeze
44-
TIMEOUT_EXCEPTIONS = [
45-
Errno::ETIMEDOUT,
46-
Async::TimeoutError
47-
].freeze
4844

4945
def initialize(*arguments, **options, &block)
5046
super
@@ -68,7 +64,7 @@ def call(env)
6864
end
6965

7066
return @app.call(env)
71-
rescue *TIMEOUT_EXCEPTIONS => e
67+
rescue Errno::ETIMEDOUT => e
7268
raise ::Faraday::TimeoutError, e
7369
rescue OpenSSL::SSL::SSLError => e
7470
raise ::Faraday::SSLError, e
@@ -83,7 +79,7 @@ def call(env)
8379

8480
def with_timeout
8581
if @timeout
86-
Async::Task.current.with_timeout(@timeout) do
82+
Async::Task.current.with_timeout(@timeout, ::Faraday::TimeoutError) do
8783
yield
8884
end
8985
else

0 commit comments

Comments
 (0)