Skip to content

Commit

Permalink
Extract log_exception method so that applications can use it as a hoo…
Browse files Browse the repository at this point in the history
…k to supply custom exception logging/notification, like Hoptoad for example.
  • Loading branch information
lukemelia committed Nov 8, 2008
1 parent 0be1cfa commit 3d52303
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/delayed/job.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 3d52303

Please sign in to comment.