class Faraday::Request::Retry

end
conn.adapter …
exceptions: [CustomException, ‘Timeout::Error’]
conn.request :retry, max: 2, interval: 0.05,
Faraday.new do |conn|
Examples
handle an a retry interval.
be configured with an arbitrary number of retries, a list of exceptions to
By default, it retries 2 times and handles only timeout exceptions. It can
Catches exceptions and retries each request a limited number of times.

def build_exception_matcher(exceptions)

responds to `===`, but for Ruby 1.8 it has to be a Class or Module.
An exception matcher for the rescue clause can usually be any object that

Private: construct an exception matcher object.
def build_exception_matcher(exceptions)
  matcher = Module.new
  (class << matcher; self; end).class_eval do
    define_method(:===) do |error|
      exceptions.any? do |ex|
        if ex.is_a? Module then error.is_a? ex
        else error.class.to_s == ex.to_s
        end
      end
    end
  end
  matcher
end

def call(env)

def call(env)
  retries = @options.max
  begin
    @app.call(env)
  rescue @errmatch
    if retries > 0
      retries -= 1
      sleep @options.interval if @options.interval > 0
      retry
    end
    raise
  end
end

def initialize(app, options = nil)

[Errno::ETIMEDOUT, Timeout::Error, Error::TimeoutError])
given as Class, Module, or String. (default:
exceptions - The list of exceptions to handle. Exceptions can be
interval - Pause in seconds between retries (default: 0).
max - Maximum number of retries (default: 2).
Options:

Public: Initialize middleware
def initialize(app, options = nil)
  super(app)
  @options = Options.from(options)
  @errmatch = build_exception_matcher(@options.exceptions)
end