Hommer Smith
Hommer Smith

Reputation: 27852

Catch exception but do retry with Sidekiq

By default sidekiq will retry any jobs that throw an exception. That is fine. However, I want to be able to catch that exception so that my exception handler doesn't get notified, and then retry the job. How do I accomplish this in react?

So my code looks like this:

def perform
  ...
rescue ExcClass => ex
  # log
end

But I want to actually retry that job.

Upvotes: 5

Views: 2889

Answers (2)

Mike Perham
Mike Perham

Reputation: 22208

Configure your error service client to ignore ExcClass. Sidekiq will retry, you don't get error reports.

Upvotes: 5

Collin Graves
Collin Graves

Reputation: 2257

If I'm following your question correctly, it sounds like you may want a custom error handler to do what you want:

Sidekiq.configure_server do |config|
  config.error_handlers << Proc.new {|exception,context_hash| MyErrorService.notify(exception,context_hash) }
end

By default, Sidekiq will continue to retry your jobs automatically.

Does this answer your question? It's slightly confusing. Here are the docs from which I pulled the above information.

Upvotes: 2

Related Questions