Module: BrowserStackCucumber::RetryHelper

Defined in:
lib/browserstack/with_rescue.rb

Class Method Summary collapse

Class Method Details

.with_rescue(exception, limit = 1, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/browserstack/with_rescue.rb', line 3

def self.with_rescue(exception, limit=1, &block)

  try=0
  begin
    block.call(try)
  rescue exception
    try+=1
    retry if try<=limit
  end
end

.with_rescue_many(exceptions, limit = 1, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/browserstack/with_rescue.rb', line 14

def self.with_rescue_many(exceptions, limit=1, &block)

  try=0
  begin
    block.call(try)
  rescue *exceptions
    try+=1
    retry if try<=limit
  end
end