From 8887b205ee571f2ccbacdb94c6eee38265cf001b Mon Sep 17 00:00:00 2001 From: woclass Date: Thu, 6 Oct 2022 12:46:58 +0800 Subject: [PATCH] catch JSONDecodeError Co-Authored-By: Takeshi HASEGAWA <2528004+hasegaw@users.noreply.github.com> --- iksm.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/iksm.py b/iksm.py index 92c85c2..e5866da 100644 --- a/iksm.py +++ b/iksm.py @@ -317,10 +317,13 @@ def get_bullet(web_service_token, web_view_ver, app_user_agent, user_lang, user_ print("Cannot access SplatNet 3 without having played online.") sys.exit(1) - bullet_resp = json.loads(r.text) try: + bullet_resp = json.loads(r.text) bullet_token = bullet_resp["bulletToken"] - except: + except (json.decoder.JSONDecodeError, TypeError): + print("Got non-JSON response from Nintendo.") + sys.exit(1) + except KeyError: print("Error from Nintendo (in api/bullet_tokens step):") print(json.dumps(bullet_resp, indent=2)) sys.exit(1)