Module: RetryOnError

Included in:
Imap::Backup::Account::Folder, Imap::Backup::Client::AutomaticLoginWrapper
Defined in:
lib/retry_on_error.rb

Instance Method Summary collapse

Instance Method Details

#retry_on_error(errors:, limit: 10) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/retry_on_error.rb', line 2

def retry_on_error(errors:, limit: 10)
  tries ||= 1
  yield
rescue *errors => e
  if tries < limit
    message = "#{e}, attempt #{tries} of #{limit}"
    Imap::Backup::Logger.logger.debug message
    tries += 1
    retry
  end
  raise e
end