Module: Magpie::Rubber

Defined in:
lib/magpie/rubber.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) try(times = 1, options = { }, &block)



4
5
6
7
8
9
10
11
12
# File 'lib/magpie/rubber.rb', line 4

def self.try(times = 1, options = { }, &block)
  val = yield times
rescue options[:on] || Exception => e
  Magpie.logger.info("#{Time.now}:#{__FILE__}:#{__LINE__}}:#{e.backtrace[0..8].join("\n")}")
  retry if (times -= 1) > 0
  raise e
else
  val
end