module Honeybadger::Plugins::Resque::Extension

def after_perform_with_honeybadger(*args)

def after_perform_with_honeybadger(*args)
  Honeybadger.clear!
end

def around_perform_with_honeybadger(*args)

errors reported within jobs get sent before the worker dies.
Executed before +on_failure+ hook; the flush is necessary so that
def around_perform_with_honeybadger(*args)
  Honeybadger.flush { yield }
end

def on_failure_with_honeybadger(e, *args)

executed after +around_perform+.
Error notifications must be synchronous as the +on_failure+ hook is
def on_failure_with_honeybadger(e, *args)
  Honeybadger.notify(e, parameters: { job_arguments: args }, sync: true) if send_exception_to_honeybadger?(e, args)
ensure
  Honeybadger.clear!
end

def send_exception_to_honeybadger?(e, args)

def send_exception_to_honeybadger?(e, args)
  return true unless respond_to?(:retry_criteria_valid?)
  return true if ::Honeybadger.config[:'resque.resque_retry.send_exceptions_when_retrying']
  !retry_criteria_valid?(e)
rescue => e
  Honeybadger.notify(e, parameters: { job_arguments: args }, sync: true)
end