catch JSONDecodeError

Co-Authored-By: Takeshi HASEGAWA <2528004+hasegaw@users.noreply.github.com>
This commit is contained in:
woclass
2022-10-06 12:46:58 +08:00
parent f1f57b74d4
commit 8887b205ee

View File

@@ -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)