diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-09-13 00:16:32 +0200 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-09-13 00:17:41 +0200 |
commit | c54514b283c47f774b0b6e9e22449ee6876ffc51 (patch) | |
tree | 72448ccecadc10c85ca2be3c022998258f08fc4c /swiftstory/SwiftStory.py | |
parent | 6157c88b1e7e47dfa9233776aa25b716e62f8af2 (diff) |
Handle exception when JSON received is not an object
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'swiftstory/SwiftStory.py')
-rw-r--r-- | swiftstory/SwiftStory.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/swiftstory/SwiftStory.py b/swiftstory/SwiftStory.py index 770e347..dc55e2a 100644 --- a/swiftstory/SwiftStory.py +++ b/swiftstory/SwiftStory.py @@ -20,7 +20,11 @@ def message_received_handler(client, message): except json.JSONDecodeError: return error('badly formatted json') - op = json_msg.get('op') + try: + op = json_msg['op'] + except (KeyError, TypeError): + op = None + if op == 'join_game': try: game_name = json_msg['game_name'] |