Reraise instead of swallow exceptions that occur beyond the retry attempts

上级 f931290e
......@@ -32,7 +32,8 @@ def retry_on(exception, wait: 3.seconds, attempts: 5, queue: nil, priority: nil)
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}."
logger.error "Stopped retrying #{self.class} due to a #{exception}, which reoccurred on #{executions} attempts. The original exception was #{error.cause.inspect}."
raise error
end
end
end
......
......@@ -35,7 +35,7 @@ class ExceptionsTest < ActiveSupport::TestCase
begin
RetryJob.perform_later 'VerySeriousError', 11
assert_equal "Raised VerySeriousError for the 10th time", JobBuffer.last_value
rescue SeriousError
rescue VerySeriousError
pass
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册