class Airbrake::Shoryuken::ErrorHandler

Provides integration with Shoryuken.

def call(worker, queue, _sqs_msg, body, &block)

rubocop:disable Lint/RescueException
def call(worker, queue, _sqs_msg, body, &block)
  timing = Airbrake::Benchmark.measure(&block)
rescue Exception => exception
  notify_airbrake(exception, worker, queue, body)
  Airbrake.notify_queue(
    queue: worker.class.to_s,
    error_count: 1,
    timing: 0.01,
  )
  raise exception
else
  Airbrake.notify_queue(
    queue: worker.class.to_s,
    error_count: 0,
    timing: timing,
  )
end

def notice_context(queue, body)

def notice_context(queue, body)
  {
    queue: queue,
    body: body.is_a?(Array) ? { batch: body } : { body: body },
  }
end

def notify_airbrake(exception, worker, queue, body)

def notify_airbrake(exception, worker, queue, body)
  Airbrake.notify(exception, notice_context(queue, body)) do |notice|
    notice[:context][:component] = 'shoryuken'
    notice[:context][:action] = worker.class.to_s
  end
end