Created
February 7, 2017 16:28
-
-
Save iloveitaly/41b7a2372026bcd8d59b07c445086f41 to your computer and use it in GitHub Desktop.
Retry Stripe operations on backend errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stripe.max_network_retries = 100 | |
# https://github.com/stripe/stripe-ruby/pull/501 | |
Stripe.class_eval do | |
def self.should_retry?(e, retry_count) | |
retry_count < self.max_network_retries && | |
( | |
Stripe::RETRY_EXCEPTIONS.any? { |klass| e.is_a?(klass) } || | |
(e.is_a?(RestClient::ExceptionWithResponse) && e.response.include?('Error while communicating with one of our backends.')) | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment