Skip to content

Instantly share code, notes, and snippets.

@osbre
Created February 2, 2025 06:51
Show Gist options
  • Save osbre/27e1e7f68e39092008b0acb4b02bbd62 to your computer and use it in GitHub Desktop.
Save osbre/27e1e7f68e39092008b0acb4b02bbd62 to your computer and use it in GitHub Desktop.
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