Commit d77120befa7f3861e2861c92965cdb6bb9008793
Committed by
Rodrigo Souto
1 parent
2076b9e3
Exists in
master
and in
28 other branches
Show object in exceptions notification of feed-updater and delayed_job
Showing
2 changed files
with
26 additions
and
9 deletions
Show diff stats
lib/feed_updater.rb
| ... | ... | @@ -20,14 +20,20 @@ end |
| 20 | 20 | class FeedUpdater |
| 21 | 21 | |
| 22 | 22 | class ExceptionNotification < ActionMailer::Base |
| 23 | - def mail error | |
| 23 | + def mail container, error | |
| 24 | 24 | environment = Environment.default |
| 25 | 25 | |
| 26 | 26 | recipients NOOSFERO_CONF['exception_recipients'] |
| 27 | 27 | from environment.contact_email |
| 28 | 28 | reply_to environment.contact_email |
| 29 | 29 | subject "[#{environment.name}] Feed-updater: #{error.message}" |
| 30 | - body render(:text => error.backtrace.join("\n")) | |
| 30 | + body render(:text => " | |
| 31 | +Container: | |
| 32 | +#{container.inspect} | |
| 33 | + | |
| 34 | +Backtrace: | |
| 35 | +#{error.backtrace.join("\n")} | |
| 36 | + ") | |
| 31 | 37 | end |
| 32 | 38 | end |
| 33 | 39 | |
| ... | ... | @@ -88,11 +94,13 @@ class FeedUpdater |
| 88 | 94 | if !running |
| 89 | 95 | break |
| 90 | 96 | end |
| 91 | - feed_handler.process(container) | |
| 97 | + begin | |
| 98 | + feed_handler.process(container) | |
| 99 | + rescue Exception => e | |
| 100 | + FeedUpdater::ExceptionNotification.deliver_mail container, e if NOOSFERO_CONF['exception_recipients'].present? | |
| 101 | + end | |
| 92 | 102 | end |
| 93 | 103 | end |
| 94 | - rescue Exception => e | |
| 95 | - FeedUpdater::ExceptionNotification.deliver_mail e if NOOSFERO_CONF['exception_recipients'].present? | |
| 96 | 104 | end |
| 97 | 105 | end |
| 98 | 106 | ... | ... |
vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb
| 1 | 1 | Delayed::Worker.module_eval do |
| 2 | 2 | # based on https://groups.google.com/forum/#!topic/delayed_job/ZGMUFFppNgs |
| 3 | 3 | class Delayed::Worker::ExceptionNotification < ActionMailer::Base |
| 4 | - def mail error | |
| 4 | + def mail job, error | |
| 5 | 5 | environment = Environment.default |
| 6 | 6 | |
| 7 | 7 | recipients NOOSFERO_CONF['exception_recipients'] |
| 8 | 8 | from environment.contact_email |
| 9 | 9 | reply_to environment.contact_email |
| 10 | - subject "[#{environment.name}] DelayedJob: #{error.message}" | |
| 11 | - body render(:text => error.backtrace.join("\n")) | |
| 10 | + subject "[#{environment.name}] DelayedJob ##{job.id}: #{error.message}" | |
| 11 | + body render(:text => " | |
| 12 | +Job: | |
| 13 | +#{job.inspect} | |
| 14 | + | |
| 15 | +Handler: | |
| 16 | +#{job.handler} | |
| 17 | + | |
| 18 | +Backtrace: | |
| 19 | +#{error.backtrace.join("\n")} | |
| 20 | + ") | |
| 12 | 21 | end |
| 13 | 22 | end |
| 14 | 23 | |
| 15 | 24 | def handle_failed_job_with_notification(job, error) |
| 16 | - Delayed::Worker::ExceptionNotification.deliver_mail error if NOOSFERO_CONF['exception_recipients'].present? | |
| 25 | + Delayed::Worker::ExceptionNotification.deliver_mail job, error if NOOSFERO_CONF['exception_recipients'].present? | |
| 17 | 26 | handle_failed_job_without_notification job, error |
| 18 | 27 | end |
| 19 | 28 | alias_method_chain :handle_failed_job, :notification | ... | ... |