File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626from 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
Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ class BlueskyRemoteControlError(Exception):
4646 pass
4747
4848
49+ class NonJsonResponseError (Exception ):
50+ pass
51+
52+
4953class 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
You can’t perform that action at this time.
0 commit comments