{"action":"created","issue":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/2072","labels_url":"https://api.github.com/repos/mperham/sidekiq/issues/2072/labels{/name}","comments_url":"https://api.github.com/repos/mperham/sidekiq/issues/2072/comments","events_url":"https://api.github.com/repos/mperham/sidekiq/issues/2072/events","html_url":"https://github.com/mperham/sidekiq/issues/2072","id":50980536,"number":2072,"title":"Do not retry for certain exceptions","user":{"login":"ollie","id":53026,"avatar_url":"https://avatars.githubusercontent.com/u/53026?v=3","gravatar_id":"","url":"https://api.github.com/users/ollie","html_url":"https://github.com/ollie","followers_url":"https://api.github.com/users/ollie/followers","following_url":"https://api.github.com/users/ollie/following{/other_user}","gists_url":"https://api.github.com/users/ollie/gists{/gist_id}","starred_url":"https://api.github.com/users/ollie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ollie/subscriptions","organizations_url":"https://api.github.com/users/ollie/orgs","repos_url":"https://api.github.com/users/ollie/repos","events_url":"https://api.github.com/users/ollie/events{/privacy}","received_events_url":"https://api.github.com/users/ollie/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2014-12-04T14:21:41Z","updated_at":"2015-07-23T13:04:38Z","closed_at":"2014-12-04T16:54:22Z","body":"Hello Mike,\r\n\r\nWhat do you think of having a declarative class method for saying \"do not retry if the error class is this and that\"? A typical use case is something like this:\r\n\r\n```ruby\r\nclass ThumbnailWorker\r\n  include Sidekiq::Worker\r\n  sidekiq_options retry: 5\r\n  # do_not_retry_if Sequel::NoMatchingRow,\r\n  #                 RemoteFetcher::ResourceNotFoundError\r\n\r\n  def perform(image_id)\r\n    # Find the DB record with URLs.\r\n    image = Image.with_pk!(image_id)\r\n    # Download the image, resize it, do whatever with it.\r\n    Thumbnailer.new(image).generate\r\n  rescue Sequel::NoMatchingRow\r\n    # There is no point in retrying since the record does not exist.\r\n  rescue RemoteFetcher::ResourceNotFoundError\r\n    # Amazon S3 said 404, no point in retrying.\r\n    # However, we DO want to try again if it was a timeout.\r\n  end\r\nend\r\n```\r\n\r\nThe point is to not retry if it doesn't make sense.\r\n\r\nThanks,\r\nOllie"},"comment":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/comments/124089313","html_url":"https://github.com/mperham/sidekiq/issues/2072#issuecomment-124089313","issue_url":"https://api.github.com/repos/mperham/sidekiq/issues/2072","id":124089313,"user":{"login":"aprescott","id":342081,"avatar_url":"https://avatars.githubusercontent.com/u/342081?v=3","gravatar_id":"","url":"https://api.github.com/users/aprescott","html_url":"https://github.com/aprescott","followers_url":"https://api.github.com/users/aprescott/followers","following_url":"https://api.github.com/users/aprescott/following{/other_user}","gists_url":"https://api.github.com/users/aprescott/gists{/gist_id}","starred_url":"https://api.github.com/users/aprescott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aprescott/subscriptions","organizations_url":"https://api.github.com/users/aprescott/orgs","repos_url":"https://api.github.com/users/aprescott/repos","events_url":"https://api.github.com/users/aprescott/events{/privacy}","received_events_url":"https://api.github.com/users/aprescott/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T13:04:38Z","updated_at":"2015-07-23T13:04:38Z","body":"I'm still struggling to see the use case.\r\n\r\nI tend to actually care about `ActiveRecord::RecordNotFound`. I almost always want an issue with a missing record to be anything but skipped over. Instead I want it in a list of retry jobs, so I can identify the problem, because it could be a sign of an underlying bug. For the cases where I expect something to potentially not exist, using methods that return `nil` instead of raising lets you `return` early.\r\n\r\nFor something like an intermittent third party API that claims there's a missing record, I want the retry because I've seen it correct itself. But again, it could be a legitimate issue with an incorrect unique ID or something. I wouldn't want to paint over problems by skipping retries.\r\n\r\nIs this something that a custom exception handler can implement along with a declarative interface at the job level?"}}