Skip to content

Commit

Permalink
Merge pull request #108 from Qiskit-Partners/Cynocracy-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cynocracy committed Feb 13, 2023
2 parents 39989e5 + 94ed33c commit ba7e607
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions qiskit_ionq/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, cause):
# See https://support.cloudflare.com/hc/en-us/articles/115003011431/
_RETRIABLE_STATUS_CODES = {
requests.codes.internal_server_error,
requests.codes.bad_gateway,
requests.codes.service_unavailable,
*list(range(520, 530)),
}
Expand All @@ -93,14 +94,15 @@ def raise_for_status(cls, response):
response (:class:`Response <requests.Response>`): An IonQ REST API response.
Raises:
IonQAPIError: instance of `cls` with error detail from `response`."""
IonQAPIError: instance of `cls` with error detail from `response`.
IonQRetriableError: instance of `cls` with error detail from `response`."""
status_code = response.status_code
if status_code == 200:
return None
res = cls.from_response(response)
raise (IonQRetriableError(res)
if _is_retriable(response.request.method, status_code)
else res)
if _is_retriable(response.request.method, status_code):
raise IonQRetriableError(res)
raise res


@classmethod
Expand Down

0 comments on commit ba7e607

Please sign in to comment.