Module: Mihari::Retriable

Included in:
Analyzers::Base, Emitters::Base
Defined in:
lib/mihari/retriable.rb

Instance Method Summary collapse

Instance Method Details

#retry_on_error(times: 3, interval: 10) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/mihari/retriable.rb', line 5

def retry_on_error(times: 3, interval: 10)
  try = 0
  begin
    try += 1
    yield
  rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE, OpenSSL::SSL::SSLError, Timeout::Error => _e
    sleep interval
    retry if try < times
    raise
  end
end