Skip to content

Commit

Permalink
Clean-up sapi request code a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
randomir committed Nov 10, 2020
1 parent c97a4be commit efd68c9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions dwave/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,8 @@ def _sapi_request(meth, *args, **kwargs):
dict: JSON decoded body
Raises:
A :class:`~dwave.cloud.exceptions.SAPIError` subclass.
A :class:`~dwave.cloud.exceptions.SAPIError` subclass, or
:class:`dwave.cloud.exceptions.RequestTimeout`
"""

caller = inspect.stack()[1].function
Expand Down Expand Up @@ -1696,15 +1697,14 @@ def _sapi_request(meth, *args, **kwargs):
raise SolverAuthenticationError(error_code=401)

try:
error_msg = response.json()['error_msg']
msg = response.json()
error_msg = msg['error_msg']
error_code = msg['error_code']
except:
error_msg = response.text

try:
error_code = response.json()['error_code']
except:
error_code = response.status_code

# NOTE: for backwards compat only. Change to: SAPIError
raise SolverError(error_msg=error_msg, error_code=error_code)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion dwave/cloud/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self):
super(CanceledFutureError, self).__init__("An error occurred reading results from a canceled request")


class InvalidAPIResponseError(Exception):
class InvalidAPIResponseError(SAPIError):
"""Raised when an invalid/unexpected response from D-Wave Solver API is received."""


Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def test_http_retry_params_from_kwargs(self):
self._verify_retry_config(retry, retry_kwargs)


class MockConfigClientIntegration(unittest.TestCase):
class ClientConfigIntegration(unittest.TestCase):

def test_custom_options(self):
"""Test custom options (request_timeout, polling_timeout, permissive_ssl)
Expand Down

0 comments on commit efd68c9

Please sign in to comment.