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:
parent
dc1203001a
commit
8c53356fc8
2 changed files with 2 additions and 2 deletions
|
@ -143,7 +143,7 @@ module Sidekiq
|
||||||
# we didn't properly finish it.
|
# we didn't properly finish it.
|
||||||
ack = false
|
ack = false
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
handle_exception(ex, job || { :job => jobstr })
|
handle_exception(ex, { :context => "Job raised exception", :job => job, :jobstr => jobstr })
|
||||||
raise
|
raise
|
||||||
ensure
|
ensure
|
||||||
work.acknowledge if ack
|
work.acknowledge if ack
|
||||||
|
|
|
@ -53,7 +53,7 @@ module Sidekiq
|
||||||
begin
|
begin
|
||||||
block.call
|
block.call
|
||||||
rescue => ex
|
rescue => ex
|
||||||
handle_exception(ex, { event: event })
|
handle_exception(ex, { context: "Exception during Sidekiq lifecycle event.", event: event })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
arr.clear
|
arr.clear
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue