From ec6099421bad222595be15f4f0b2596952d8c9cc Mon Sep 17 00:00:00 2001 From: MrLolEthan Date: Tue, 7 Apr 2015 21:09:32 -0230 Subject: [PATCH] Improve robustness: surround the 'id' fetch from result array with a try clause. --- username_to_uuid.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/username_to_uuid.py b/username_to_uuid.py index 0e40a3d..afc596e 100644 --- a/username_to_uuid.py +++ b/username_to_uuid.py @@ -33,6 +33,9 @@ class UsernameToUUID: return "" json_data = json.loads(response) - uuid = json_data['id'] + try: + uuid = json_data['id'] + except KeyError as e: + print("KeyError raised:", e); return uuid