From f931290e58b2e62b56eca55b1ef45c794886e6cb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 29 Jul 2016 15:07:50 -0700 Subject: Proper logging when we bail on retrying after X attempts --- activejob/lib/active_job/exceptions.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'activejob/lib/active_job/exceptions.rb') diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb index 006b067bcf..eead8daae3 100644 --- a/activejob/lib/active_job/exceptions.rb +++ b/activejob/lib/active_job/exceptions.rb @@ -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| - 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 + 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 + 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 -- cgit v1.2.3