module SidekiqRemappableErrors::InstanceMethods

Attributes

retry_count[W]

Public Instance Methods

remappable_retries_exhausted?() click to toggle source
# File lib/sidekiq_remappable_errors.rb, line 75
def remappable_retries_exhausted?
  retry_count >= [
    sidekiq_max_retries,
    self.class.remappable_errors_options_store[:max_remaps]
  ].min
end
retry_count() click to toggle source
# File lib/sidekiq_remappable_errors.rb, line 71
def retry_count
  @retry_count || 0
end

Private Instance Methods

remappable_error?(error) click to toggle source
# File lib/sidekiq_remappable_errors.rb, line 93
def remappable_error?(error)
  self.class.error_matchers_store.any? do |remappable_error|
    remappable_error.match?(error)
  end
end
sidekiq_max_retries() click to toggle source
# File lib/sidekiq_remappable_errors.rb, line 99
def sidekiq_max_retries
  @_sidekiq_max_retries ||= begin
    retry_opt = sidekiq_options[:retry]

    # 25 is the hardcoded default in Sidekiq
    case retry_opt
      when false then 0
      when true then 25
      else retry_opt
    end
  end
end
sidekiq_options() click to toggle source
# File lib/sidekiq_remappable_errors.rb, line 112
def sidekiq_options
  @_sidekiq_options ||= self.class.get_sidekiq_options.transform_keys(&:to_sym)
end
with_remappable_errors() { || ... } click to toggle source
# File lib/sidekiq_remappable_errors.rb, line 84
def with_remappable_errors
  yield
rescue StandardError => e
  raise unless remappable_error?(e)
  raise if remappable_retries_exhausted?

  raise SidekiqRemappableErrors.config.remapped_error_class, e.inspect
end