From 3b4a369586733e2e15156e2dfd44af7da8ede1e2 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Fri, 5 May 2017 20:26:23 +0200 Subject: [PATCH] Improved error handling in send() --- fbchat/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fbchat/client.py b/fbchat/client.py index ffa77cc..06d994f 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -539,7 +539,8 @@ class Client(object): message_ids = [] try: message_ids += [action['message_id'] for action in j['payload']['actions'] if 'message_id' in action] - except KeyError as e: + message_ids[0] # Try accessing element + except (KeyError, IndexError) as e: log.warning('Error when sending message: No message ids could be found') return False