module SidekiqRemappableErrors::ClassMethods

Public Instance Methods

initialize_remappable_errors() click to toggle source
# File lib/sidekiq_remappable_errors.rb, line 29
def initialize_remappable_errors
  define_singleton_method(:error_matchers_store) { [] }
  define_singleton_method(:remappable_errors_options_store) {
    { max_remaps: 5 }
  }
end
remappable_errors(errors) click to toggle source

2D array of error class + message regex. If a raised error matches that class and it's error matches that regex the class will be remapped.

e.g. remappable_errors [

[ ActiveRecord::RecordNotFound, /trainer/i ],
[ FlakyService::ServiceUnvailable, // ],

]

# File lib/sidekiq_remappable_errors.rb, line 47
def remappable_errors(errors)
  current_errors = error_matchers_store
  new_errors = errors.map { |error| ErrorMatcher.new(error) }

  define_singleton_method(:error_matchers_store) { current_errors + new_errors }
end
remappable_errors_options(**opts) click to toggle source

Define remapping behavior

e.g. remappable_errors_options max_remaps: <<Integer>>

# File lib/sidekiq_remappable_errors.rb, line 59
def remappable_errors_options(**opts)
  current_options = remappable_errors_options_store

  define_singleton_method(:remappable_errors_options_store) {
    current_options.merge(opts)
  }
end