Skip to content

Commit

Permalink
IonQ: Include json body of error response when possible (quantumlib#5349
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Cynocracy authored Jun 6, 2022
1 parent 7bb4a99 commit f28361a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cirq-ionq/cirq_ionq/ionq_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import time
import urllib
from typing import Any, Callable, cast, Dict, List, Optional
import json.decoder as jd

import requests

Expand Down Expand Up @@ -301,11 +302,17 @@ def _make_request(
'IonQ could not find requested resource.'
)
if not _is_retriable(response.status_code):
error = {}
try:
error = response.json()
except jd.JSONDecodeError: # coverage: ignore
pass # coverage: ignore
raise ionq_exceptions.IonQException(
'Non-retry-able error making request to IonQ API. '
f'Request Body: {json} '
f'Response Body: {error} '
f'Status: {response.status_code} '
f'Error :{response.reason}',
f'Error:{response.reason}',
response.status_code,
)
message = response.reason
Expand Down

0 comments on commit f28361a

Please sign in to comment.