From 2f70888f4bf4214b356247bc36b561a9b9969b24 Mon Sep 17 00:00:00 2001 From: extreme4all <40169115+extreme4all@users.noreply.github.com> Date: Sat, 7 Sep 2024 15:10:23 +0200 Subject: [PATCH] some extra error handling --- api/cogs/requests.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/api/cogs/requests.py b/api/cogs/requests.py index 7ccd9c2..991919f 100644 --- a/api/cogs/requests.py +++ b/api/cogs/requests.py @@ -138,7 +138,17 @@ async def get_hiscore_data(label_id: int, limit: int = 5000): break # Increment the page parameter for the next request - params["player_id"] = data[-1]["Player_id"] + last_record = data[-1] + if not isinstance(last_record, dict): + logger.error(f"expected dict but got {type(last_record)}, {last_record=}") + break + + last_player_id = data.get("Player_id", None) + if last_player_id is None: + logger.error(f"expected int but got None, {last_record=}") + break + + params["player_id"] = last_player_id return hiscores