Module: Invoca::Utils
- Defined in:
- lib/invoca/utils.rb,
lib/invoca/utils/diff.rb,
lib/invoca/utils/diff.rb,
lib/invoca/utils/version.rb,
lib/invoca/utils/exceptions.rb,
lib/invoca/utils/multi_sender.rb,
lib/invoca/utils/guaranteed_utf8_string.rb
Defined Under Namespace
Modules: Diffable Classes: Diff, GuaranteedUTF8String, MultiSender
Constant Summary collapse
- VERSION =
"0.6.0"
Class Method Summary collapse
-
.retry_on_exception(exception_classes, retries: 1, before_retry: nil) {|retries| ... } ⇒ Object
Yields and rescues any exceptions given in ‘exception_classes`, retrying the given number of times.
Class Method Details
.retry_on_exception(exception_classes, retries: 1, before_retry: nil) {|retries| ... } ⇒ Object
Yields and rescues any exceptions given in ‘exception_classes`, retrying the given number of times. The final retry does not rescue any exceptions. The try number (0..retries) is yielded as a block param.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/invoca/utils/exceptions.rb', line 14 def retry_on_exception(exception_classes, retries: 1, before_retry: nil) retries.times do |attempt_number| begin return yield(attempt_number) rescue *Array(exception_classes) => ex before_retry&.call(ex) end end yield(retries) # no rescue for this last try, so any exceptions will raise out end |