Sha256: 9fb03a750e8caf29a816bec8f5d235c285e75854c21fa59c74cbc806d6d1043b
Contents?: true
Size: 583 Bytes
Versions: 1
Compression:
Stored size: 583 Bytes
Contents
module Houston def self.try(options, *rescue_from) options = { max_tries: options } if options.is_a?(Fixnum) options = {} unless options.is_a?(Hash) max_tries = options.fetch :max_tries, 3 base = options.fetch :base, 2 ignore = options.fetch :ignore, false tries = 1 begin yield tries rescue *rescue_from unless (tries += 1) <= max_tries return if ignore raise end Rails.logger.warn "\e[31m[try] \e[1m#{$!.class}\e[0;31m: #{$!.message}\e[0m" sleep base ** tries retry end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
houston-core-0.5.0.beta1 | config/initializers/houston_try.rb |