1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Proper logging when we bail on retrying after X attempts

This commit is contained in:
David Heinemeier Hansson 2016-07-29 15:07:50 -07:00
parent 8457e5eb1d
commit f931290e58

View file

@ -28,8 +28,12 @@ module ActiveJob
# end
def retry_on(exception, wait: 3.seconds, attempts: 5, queue: nil, priority: nil)
rescue_from exception do |error|
if executions < attempts
logger.error "Retrying #{self.class} in #{wait} seconds, due to a #{exception}. The original exception was #{error.cause.inspect}."
retry_job wait: wait, queue: queue, priority: priority if executions < attempts
retry_job wait: wait, queue: queue, priority: priority
else
logger.error "Discarded #{self.class} due to a #{exception} which reoccurred on #{executions} attempts. The original exception was #{error.cause.inspect}."
end
end
end