Module: Strobe::Retryable

Included in:
Strobe::Resources::Application
Defined in:
lib/strobe/retryable.rb

Instance Method Summary collapse

Instance Method Details

#retry_on_error(e, retries = 2) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/strobe/retryable.rb', line 3

def retry_on_error(e, retries = 2)
  e = Array.wrap(e)

  tries = 0
  begin
    yield
  rescue *e
    tries += 1
    if tries <= retries
      retry
    else
      raise
    end
  end
end