Is there a exception_notification-like gem for delayed_job? Preferably that works with REE-1.8.7 and Rails 2.3.10.
I've done something like this in the past for delayed job rake tasks:
require 'action_mailer'
class ExceptionMailer < ActionMailer::Base
def setup_mail
@from = ExceptionNotifier.sender_address
@sent_on = Time.now
@content_type = "text/plain"
end
def exception_message(subject, message)
setup_mail
@subject = subject
@recipients = ExceptionNotifier.exception_recipients
@body = message
end
end
namespace :jobs do
desc "sync the local database with the remote CMS"
task(:sync_cms => :environment) do
Resort.sync_all!
result = Delayed::Job.work_off
unless result[1].zero?
ExceptionMailer.deliver_exception_message("[SYNC CMS] Error syncing CMS id: #{Delayed::Job.last.id}", Delayed::Job.last.last_error)
end
end
end