You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: activejob/lib/active_job/exceptions.rb
+13-6Lines changed: 13 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ module ClassMethods
34
34
# * <tt>:queue</tt> - Re-enqueues the job on a different queue
35
35
# * <tt>:priority</tt> - Re-enqueues the job with a different priority
36
36
# * <tt>:jitter</tt> - A random delay of wait time used when calculating backoff. The default is 15% (0.15) which represents the upper bound of possible wait time (expressed as a percentage)
37
+
# * <tt>:report</tt> - Errors will be reported to the Rails.error reporter before being retried
# Discard the job with no attempts to retry, if the exception is raised. This is useful when the subject of the job,
83
86
# like an Active Record, is no longer available, and the job is thus no longer relevant.
84
87
#
88
+
# Passing the <tt>:report</tt> option reporter the error through the error reporter before discarding the job.
89
+
#
85
90
# You can also pass a block that'll be invoked. This block is yielded with the job instance as the first and the error instance as the second parameter.
86
91
#
87
92
# +retry_on+ and +discard_on+ handlers are searched from bottom to top, and up the class hierarchy. The handler of the first class for
retry_on(CustomCatchError){ |job,error| JobBuffer.add("Dealt with a job that failed to retry in a custom way after #{job.arguments.second} attempts. Message: #{error.message}")}
@@ -19,6 +20,7 @@ class ChildAfterDiscardError < AfterDiscardError; end
19
20
20
21
discard_onDiscardableError
21
22
discard_on(CustomDiscardableError){ |_job,error| JobBuffer.add("Dealt with a job that was discarded in a custom way. Message: #{error.message}")}
23
+
discard_on(ReportedError,report: true)
22
24
23
25
after_discard{ |_job,error| JobBuffer.add("Ran after_discard for job. Message: #{error.message}")}
@@ -31,6 +32,7 @@ class RetryJob < ActiveJob::Base
31
32
retry_on(CustomCatchError){ |job,error| JobBuffer.add("Dealt with a job that failed to retry in a custom way after #{job.arguments.second} attempts. Message: #{error.message}")}
32
33
retry_on(ActiveJob::DeserializationError){ |job,error| JobBuffer.add("Raised #{error.class} for the #{job.executions} time")}
0 commit comments