lib/imap/backup/retry_on_error.rb in imap-backup-15.0.1 vs lib/imap/backup/retry_on_error.rb in imap-backup-15.0.2

- old
+ new

@@ -11,12 +11,12 @@ # @param errors [Array<Exception>] the exceptions to trap # @param limit [Integer] the maximum number of retries # @param on_error [Proc] a block to call when an error occurs # @raise any error ocurring more than `limit` times # @return the result of any successful completion of the block - def retry_on_error(errors:, limit: 10, on_error: nil) + def retry_on_error(errors:, limit: 10, on_error: nil, &block) tries ||= 1 - yield + block.call rescue *errors => e if tries < limit message = "#{e}, attempt #{tries} of #{limit}" Logger.logger.debug message on_error&.call