From b6b8241d8df408a427a38d3b9a44837f07cfab32 Mon Sep 17 00:00:00 2001 From: Harmon Date: Thu, 14 Apr 2022 17:53:05 -0500 Subject: [PATCH] Fallback to detail response value for HTTPException message --- tweepy/errors.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tweepy/errors.py b/tweepy/errors.py index b18a3f9..309c6be 100644 --- a/tweepy/errors.py +++ b/tweepy/errors.py @@ -59,6 +59,12 @@ class HTTPException(TweepyException): error_text += f"\n{error['code']} - {error['message']}" elif "message" in error: error_text += '\n' + error["message"] + + # Use := when support for Python 3.7 is dropped + if not error_text and "detail" in response_json: + self.api_messages.append(response_json["detail"]) + error_text = '\n' + response_json["detail"] + super().__init__( f"{response.status_code} {response.reason}{error_text}" ) -- 2.25.1