Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extract log_exception method so that applications can use it as a hoo…

…k to supply custom exception logging/notification, like Hoptoad for example.
  • Loading branch information...
commit 3d52303959723bd9c1aa3505bbcfe079c29d58fb 1 parent 0be1cfa
@lukemelia lukemelia authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/delayed/job.rb
View
9 lib/delayed/job.rb
@@ -107,8 +107,7 @@ def self.reserve(max_run_time = 4.hours)
logger.warn "* [JOB] failed to aquire exclusive lock for #{job.name}"
rescue StandardError => e
job.reschedule e.message
- logger.error "* [JOB] #{job.name} failed with #{e.class.name}: #{e.message} - #{job.attempts} failed attempts"
- logger.error(e)
+ log_exception(job, error)
return job
end
end
@@ -155,6 +154,12 @@ def unlock
self.locked_by = nil
end
+ # This is a good hook if you need to report job processing errors in additional or different ways
+ def self.log_exception(job, error)
+ logger.error "* [JOB] #{job.name} failed with #{error.class.name}: #{error.message} - #{job.attempts} failed attempts"
+ logger.error(error)
+ end
+
def self.work_off(num = 100)
success, failure = 0, 0
Please sign in to comment.
Something went wrong with that request. Please try again.