From d77120befa7f3861e2861c92965cdb6bb9008793 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Wed, 16 Oct 2013 09:20:29 -0300 Subject: [PATCH] Show object in exceptions notification of feed-updater and delayed_job --- lib/feed_updater.rb | 18 +++++++++++++----- vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/feed_updater.rb b/lib/feed_updater.rb index 0d579d0..fc080f1 100644 --- a/lib/feed_updater.rb +++ b/lib/feed_updater.rb @@ -20,14 +20,20 @@ end class FeedUpdater class ExceptionNotification < ActionMailer::Base - def mail error + def mail container, error environment = Environment.default recipients NOOSFERO_CONF['exception_recipients'] from environment.contact_email reply_to environment.contact_email subject "[#{environment.name}] Feed-updater: #{error.message}" - body render(:text => error.backtrace.join("\n")) + body render(:text => " +Container: +#{container.inspect} + +Backtrace: +#{error.backtrace.join("\n")} + ") end end @@ -88,11 +94,13 @@ class FeedUpdater if !running break end - feed_handler.process(container) + begin + feed_handler.process(container) + rescue Exception => e + FeedUpdater::ExceptionNotification.deliver_mail container, e if NOOSFERO_CONF['exception_recipients'].present? + end end end - rescue Exception => e - FeedUpdater::ExceptionNotification.deliver_mail e if NOOSFERO_CONF['exception_recipients'].present? end end diff --git a/vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb b/vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb index 5df3184..7c0a43d 100644 --- a/vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb +++ b/vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb @@ -1,19 +1,28 @@ Delayed::Worker.module_eval do # based on https://groups.google.com/forum/#!topic/delayed_job/ZGMUFFppNgs class Delayed::Worker::ExceptionNotification < ActionMailer::Base - def mail error + def mail job, error environment = Environment.default recipients NOOSFERO_CONF['exception_recipients'] from environment.contact_email reply_to environment.contact_email - subject "[#{environment.name}] DelayedJob: #{error.message}" - body render(:text => error.backtrace.join("\n")) + subject "[#{environment.name}] DelayedJob ##{job.id}: #{error.message}" + body render(:text => " +Job: +#{job.inspect} + +Handler: +#{job.handler} + +Backtrace: +#{error.backtrace.join("\n")} + ") end end def handle_failed_job_with_notification(job, error) - Delayed::Worker::ExceptionNotification.deliver_mail error if NOOSFERO_CONF['exception_recipients'].present? + Delayed::Worker::ExceptionNotification.deliver_mail job, error if NOOSFERO_CONF['exception_recipients'].present? handle_failed_job_without_notification job, error end alias_method_chain :handle_failed_job, :notification -- libgit2 0.21.2