Created
February 2, 2025 06:51
-
-
Save osbre/27e1e7f68e39092008b0acb4b02bbd62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
products = retry_on_failure(times: 2) do | |
account.client.products.all | |
rescue => e | |
account.refresh_token | |
raise e | |
end | |
private | |
def retry_on_failure(times: , &block) | |
retries ||= 0 | |
block.call | |
rescue => e | |
retries += 1 | |
retry if retries < times | |
raise e | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment