From: Harmon Date: Thu, 14 Apr 2022 22:53:05 +0000 (-0500) Subject: Fallback to detail response value for HTTPException message X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b6b8241d8df408a427a38d3b9a44837f07cfab32;p=tweepy.git Fallback to detail response value for HTTPException message --- 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}" )