Method: Sidekiq::JobRetry#local

Defined in:
lib/sidekiq/job_retry.rb

#local(jobinst, jobstr, queue) ⇒ Object

The local retry support means that any errors that occur within this block can be associated with the given job instance. This is required to support the sidekiq_retries_exhausted block.

Note that any exception from the block is wrapped in the Skip exception so the global block does not reprocess the error. The Skip exception is unwrapped within Sidekiq::Processor#process before calling the handle_exception handlers.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/sidekiq/job_retry.rb', line 117

def local(jobinst, jobstr, queue)
  yield
rescue Handled => ex
  raise ex
rescue Sidekiq::Shutdown => ey
  # ignore, will be pushed back onto queue during hard_shutdown
  raise ey
rescue Exception => e
  # ignore, will be pushed back onto queue during hard_shutdown
  raise Sidekiq::Shutdown if exception_caused_by_shutdown?(e)

  msg = Sidekiq.load_json(jobstr)
  if msg["retry"].nil?
    msg["retry"] = jobinst.class.get_sidekiq_options["retry"]
  end

  raise e unless msg["retry"]
  process_retry(jobinst, msg, queue, e)
  # We've handled this error associated with this job, don't
  # need to handle it at the global level
  raise Handled
end