Skip to content

Commit

Permalink
Skip logging rescuable exceptions which are defined in rescue_from/re…
Browse files Browse the repository at this point in the history
…try_on/discard_on.

Update activejob/CHANGELOG.md

Co-authored-by: Rafael França <[email protected]>
  • Loading branch information
islue and rafaelfranca committed Dec 31, 2020
1 parent c02d9e5 commit 0c6f32a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions activejob/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
* Skip logging rescuable exceptions which are defined in rescue_from/retry_on/discard_on.

*Hu Hailin*


Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/activejob/CHANGELOG.md) for previous changes.
6 changes: 4 additions & 2 deletions activejob/lib/active_job/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ def perform(event)
job = event.payload[:job]
ex = event.payload[:exception_object]
if ex
error do
"Error performing #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)} in #{event.duration.round(2)}ms: #{ex.class} (#{ex.message}):\n" + Array(ex.backtrace).join("\n")
unless job.class.rescue_handlers.any? { |handler| handler[0] == event.payload[:exception][0] }
error do
"Error performing #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)} in #{event.duration.round(2)}ms: #{ex.class} (#{ex.message}):\n" + Array(ex.backtrace).join("\n")
end
end
elsif event.payload[:aborted]
error do
Expand Down

0 comments on commit 0c6f32a

Please sign in to comment.