Skip to content

Commit

Permalink
improve consistency between HTTP clients
Browse files Browse the repository at this point in the history
This commit modifies `PycurlClient` to set the `should_retry` attribute of `APIConnectionError` exceptions, like `RequestsClient` does.
  • Loading branch information
Changaco authored Aug 12, 2019
1 parent ccef833 commit aba93a6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stripe/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,21 +494,24 @@ def _handle_request_error(self, e):
"https://twitter.com/stripestatus, or let us know at "
"support@stripe.com."
)
should_retry = True
elif e.args[0] in [pycurl.E_SSL_CACERT, pycurl.E_SSL_PEER_CERTIFICATE]:
msg = (
"Could not verify Stripe's SSL certificate. Please make "
"sure that your network is not intercepting certificates. "
"If this problem persists, let us know at "
"support@stripe.com."
)
should_retry = False
else:
msg = (
"Unexpected error communicating with Stripe. If this "
"problem persists, let us know at support@stripe.com."
)
should_retry = False

msg = textwrap.fill(msg) + "\n\n(Network error: " + e.args[1] + ")"
raise error.APIConnectionError(msg)
raise error.APIConnectionError(msg, should_retry=should_retry)

def _get_proxy(self, url):
if self._proxy:
Expand Down

0 comments on commit aba93a6

Please sign in to comment.