class Sidekiq::JobRetry

def retries_exhausted(jobinst, msg, exception)

def retries_exhausted(jobinst, msg, exception)
  begin
    block = jobinst&.sidekiq_retries_exhausted_block
    block&.call(msg, exception)
  rescue => e
    handle_exception(e, {context: "Error calling retries_exhausted", job: msg})
  end
  send_to_morgue(msg) unless msg["dead"] == false
  @capsule.config.death_handlers.each do |handler|
    handler.call(msg, exception)
  rescue => e
    handle_exception(e, {context: "Error calling death handler", job: msg})
  end
end