retriable icon indicating copy to clipboard operation
retriable copied to clipboard

Allow not to retry some exceptions

Open fatkodima opened this issue 5 years ago • 1 comments

This is very useful when you want to retry a lot of types of exceptions, except for, let's say, one. And to not list all of them, you can just type :on with :not.

class UnreliableServiceException < StandardError; end
class ServiceUnavailableException < UnreliableServiceException; end
class LimitExceededException < UnreliableServiceException; end
# ... 10 more exception classes...
class AccountExpiredException < UnreliableServiceException; end

Retriable.retriable(on: UnreliableServiceException, not: AccountExpiredException) do
  # do something
end

Non whitespace changes

fatkodima avatar Aug 25 '19 19:08 fatkodima

I think this is a good idea!

Sylor-huang avatar Mar 22 '21 08:03 Sylor-huang