mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 20:33:14 +08:00
When checking how many times an email job has been retried, we need to check that the `retry_count` attribute has been set. In a related error, the `UserEmail` retry wait handler assumed that the triggering exception would always have a `wrapped` attribute, which isn't necessarily the case if the exception was raised outside of the job execution code.
16 lines
418 B
Ruby
16 lines
418 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Sidekiq
|
|
class SuppressUserEmailErrors
|
|
def call(worker, job, queue)
|
|
yield
|
|
rescue => e
|
|
# Only suppress email errors from Jobs::UserEmail, and only for the first 3 retries
|
|
if worker.class == Jobs::UserEmail && !job["retry_count"].nil? && job["retry_count"] < 3
|
|
raise Jobs::HandledExceptionWrapper.new(e)
|
|
end
|
|
|
|
raise e
|
|
end
|
|
end
|
|
end
|