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
Ruby Time Object Converted from Float Doesn't Equal to Orignial Time Object
Ruby: Merge Two Hash as One and with Value Connected
How to Access the Base Namespace in Ruby
Ruby Gem Listed, But Won't Load (Gem in User Dir, Not Ruby Dir)
Get Jekyll Configuration Inside Plugin
Ruby Net::Smtp - Send Email with Bcc: Recipients
Running Webrick Server in Background
Vim Ruby Mismatch on MAC High Sierra
In Ruby What's the Difference Between Self.Method and a Method Within Class << Self
Ruby String with Usd "Money" Converted to Number
Whenever Gem: I Set :Output But the Logfile Doesn't Show Up Where I'D Expect It To
Testing Simple Sti with Factorygirl