Module: Delayed::Plugins::Bugsnag::Notify

Defined in:
lib/bugsnag/delayed_job.rb

Instance Method Summary collapse

Instance Method Details

#error(job, error) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bugsnag/delayed_job.rb', line 15

def error(job, error)
  overrides = {
    :job => {
      :class => job.class.name,
      :id => job.id,
    }
  }
  if payload = job.payload_object
    p = {
      :class => payload.class.name,
    }
    p[:id]           = payload.id           if payload.respond_to?(:id)
    p[:display_name] = payload.display_name if payload.respond_to?(:display_name)
    p[:method_name]  = payload.method_name  if payload.respond_to?(:method_name)
    p[:args]         = payload.args         if payload.respond_to?(:args)
    if payload.is_a?(::Delayed::PerformableMethod) && (object = payload.object)
      p[:object] = {
        :class => object.class.name,
      }
      p[:object][:id] = object.id if object.respond_to?(:id)
    end
    overrides[:job][:payload] = p
  end

  ::Bugsnag.auto_notify(error, overrides)

  super if defined?(super)
end