How to Integrate Hoptoad with Delayedjob and Daemonspawn

How to make Delayed_Job notify Airbrake when an ActionMailer runs into an error?

I was just searching for a solution to this problem too, and I found this gist.

I don't know where it comes from (found it on Google), but well, it seems to do the job pretty well, is quite simple, and seems to follow a DelayedJob's plugin system I was not even aware of...

Here is a lightly improved one using parts of previous monkey-patch code:

# https://gist.github.com/2223758
# modified

module Delayed
module Plugins
class Airbrake < Plugin
module Notify
def error(job, error)
::Airbrake.notify_or_ignore(
:error_class => error.class.name,
:error_message => "#{error.class.name}: #{error.message}",
:parameters => {
:failed_job => job.inspect,
}
)
super if defined?(super)
end
end

callbacks do |lifecycle|
lifecycle.before(:invoke_job) do |job|
payload = job.payload_object
payload = payload.object if payload.is_a? Delayed::PerformableMethod
payload.extend Notify
end
end
end
end
end

Delayed::Worker.plugins << Delayed::Plugins::Airbrake

It will add the error's message and payload so that it's available in Airbrake.

HttpParty::Response and try(:parsed_response) weird behavior

Have no idea how, but seems like ro object was "transfered" into a hash that has been sent a parsed_response method.

In Rails 2.3@ruby 1.8 undefined method for object raises an exception.

Besides, docs stay only for calling try on nil object and nothing about the object that doesn't have a specific method:

Unlike that method however, a NoMethodError exception will not be
raised and nil will be returned instead, if the receiving object is a
nil object or NilClass.



Related Topics



Leave a reply



Submit