Class: Pictify::Client::TimeoutClassifier
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Pictify::Client::TimeoutClassifier
- Defined in:
- lib/pictify/client.rb
Overview
Runs between the retry middleware and the adapter. The net_http adapter
wraps Net::OpenTimeout as Faraday::ConnectionFailed, which would slip
a timeout past a retry exception list that (deliberately) excludes
timeouts — so timeout-flavored connection failures are re-raised as
Faraday::TimeoutError before the retry middleware sees them.
Constant Summary collapse
- TIMEOUT_HINTS =
["timeout", "timed out", "execution expired"].freeze
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
423 424 425 426 427 428 429 430 |
# File 'lib/pictify/client.rb', line 423 def call(env) @app.call(env) rescue Faraday::ConnectionFailed => e raise Faraday::TimeoutError, e if e.cause.is_a?(Timeout::Error) || TIMEOUT_HINTS.any? { |hint| e..to_s.downcase.include?(hint) } raise end |