Module: Ferrum::Utils::Attempt

Defined in:
lib/ferrum/utils/attempt.rb

Class Method Summary collapse

Class Method Details

.with_retry(errors:, max:, wait:) ⇒ Object


8
9
10
11
12
13
14
15
16
17
# File 'lib/ferrum/utils/attempt.rb', line 8

def with_retry(errors:, max:, wait:)
  attempts ||= 1
  yield
rescue *Array(errors)
  raise if attempts >= max

  attempts += 1
  sleep(wait)
  retry
end