1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Provide consistent interface to exception handlers (#3161)

This commit ensures that exception handlers are always provided with two objects:

* The Exception
* A hash with the following keys:
  * `:context` (Required) - A String message explaining what happened
  * `:job` (Optional) - If this occurred while a job was being processed, this is the deserialized job Hash
  * `:jobstr` (Optional) - If this occurred during job deserialization, this is the raw JSON string of the job
  * `:event` (Optional) - If this occurred during a lifecycle event, name of the event
This commit is contained in:
Nate Berkopec 2016-09-26 14:51:13 -06:00 committed by Mike Perham
parent dc1203001a
commit 8c53356fc8
2 changed files with 2 additions and 2 deletions

View file

@ -143,7 +143,7 @@ module Sidekiq
# we didn't properly finish it.
ack = false
rescue Exception => ex
handle_exception(ex, job || { :job => jobstr })
handle_exception(ex, { :context => "Job raised exception", :job => job, :jobstr => jobstr })
raise
ensure
work.acknowledge if ack

View file

@ -53,7 +53,7 @@ module Sidekiq
begin
block.call
rescue => ex
handle_exception(ex, { event: event })
handle_exception(ex, { context: "Exception during Sidekiq lifecycle event.", event: event })
end
end
arr.clear