Skip to content

Commit a6ad517

Browse files
committed
updates after second review
1 parent 51f99f3 commit a6ad517

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/blueapi/cli/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from blueapi.client.rest import (
2727
BlueskyRemoteControlError,
2828
InvalidParametersError,
29+
NonJsonResponseError,
2930
ServiceUnavailableError,
3031
UnauthorisedAccessError,
3132
UnknownPlanError,
@@ -521,7 +522,7 @@ def login(obj: dict) -> None:
521522
auth.start_device_flow()
522523
else:
523524
print("Server is not configured to use authentication!")
524-
except BlueskyRemoteControlError as e:
525+
except NonJsonResponseError as e:
525526
print(str(e))
526527

527528

src/blueapi/client/rest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class BlueskyRemoteControlError(Exception):
4646
pass
4747

4848

49+
class NonJsonResponseError(Exception):
50+
pass
51+
52+
4953
class BlueskyRequestError(Exception):
5054
def __init__(self, code: int, message: str) -> None:
5155
super().__init__(message, code)
@@ -139,11 +143,14 @@ def _create_task_exceptions(response: requests.Response) -> Exception | None:
139143
return BlueskyRequestError(code, response.text)
140144

141145

142-
def _response_json(response) -> Any:
146+
def _response_json(response: requests.Response) -> Any:
143147
try:
144148
return response.json()
145149
except json.decoder.JSONDecodeError as exc:
146-
raise BlueskyRemoteControlError(
150+
LOGGER.debug(
151+
f"Invalid json response from <{response.request.url}>: <{response.content}>"
152+
)
153+
raise NonJsonResponseError(
147154
"Response does not contain a valid JSON object"
148155
) from exc
149156

0 commit comments

Comments
 (0)