You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: retry_on_error.rb
    path of file: ./repos/imap-backup/lib/imap/backup
    
    the code of the file until where you have to start completion: require "imap/backup/logger"

module Imap; end

module Imap::Backup
  # Provides a mecha
    
    def retry_on_error(errors:, limit: 10, on_error: nil)
      tries ||= 1
      yield
    rescue *errors => e
      if tries < limit
        message = "#{e}, attempt #{tries} of #{limit}"
        Logger.logger.debug message
        on_error&.call
        tries += 1
        retry
      end