From c7847bac01e4f5c67f7960d0eea85f4e32130315 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sun, 4 Apr 2021 10:07:55 -0500 Subject: [PATCH] Handle Twitter API errors with successful HTTP status codes --- tweepy/parsers.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tweepy/parsers.py b/tweepy/parsers.py index a0ca907..916866c 100644 --- a/tweepy/parsers.py +++ b/tweepy/parsers.py @@ -73,10 +73,15 @@ class ModelParser(JSONParser): else: cursors = None - if payload_list: - result = model.parse_list(api, json) - else: - result = model.parse(api, json) + try: + if payload_list: + result = model.parse_list(api, json) + else: + result = model.parse(api, json) + except KeyError: + raise TweepyException( + f"Unable to parse response payload: {json}" + ) from None if cursors: return result, cursors -- 2.25.1