@@ -277,7 +277,9 @@ def _parse_params(
277277 return parameters
278278
279279 @staticmethod
280- def _parse_results (response : LpdbResponse ) -> list [dict [str , Any ]]:
280+ def _parse_results (
281+ status_code : int , response : LpdbResponse
282+ ) -> list [dict [str , Any ]]:
281283 result = response ["result" ]
282284 lpdb_warnings = response .get ("warning" )
283285 lpdb_errors = response .get ("error" )
@@ -292,6 +294,9 @@ def _parse_results(response: LpdbResponse) -> list[dict[str, Any]]:
292294 wiki = rate_limit .group ("wiki" ), table = rate_limit .group ("table" )
293295 )
294296 raise LpdbError (re .sub (r"^Error: ?" , "" , lpdb_errors [0 ]))
297+ elif status_code != HTTPStatus .OK :
298+ status = HTTPStatus (status_code )
299+ raise LpdbError (f"HTTP { status_code } : { status .name } " )
295300 if lpdb_warnings and len (lpdb_warnings ) != 0 :
296301 for lpdb_warning in lpdb_warnings :
297302 warnings .warn (lpdb_warning , LpdbWarning )
@@ -315,13 +320,8 @@ def get_wikis() -> set[str]:
315320
316321 @staticmethod
317322 def __handle_response (response : requests .Response ) -> list [dict [str , Any ]]:
318- try :
319- return AbstractLpdbSession ._parse_results (response .json ())
320- except Exception as e :
321- if isinstance (e , LpdbError ):
322- raise e
323- status = HTTPStatus (response .status_code )
324- raise LpdbError (f"HTTP { status } : { status .name } " ) from e
323+ status = HTTPStatus (response .status_code )
324+ return AbstractLpdbSession ._parse_results (status , response .json ())
325325
326326 @override
327327 def make_request (
0 commit comments