From: Harmon Date: Thu, 24 Mar 2022 06:18:30 +0000 (-0500) Subject: Raise NotFound when encountering 404 status codes in BaseClient.request X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b6b82196d3f0821c184901de985e2cedb56a9db2;p=tweepy.git Raise NotFound when encountering 404 status codes in BaseClient.request Raise NotFound rather than HTTPException when encountering 404 response status codes in BaseClient.request --- diff --git a/tweepy/client.py b/tweepy/client.py index 8937fe9..819aee5 100644 --- a/tweepy/client.py +++ b/tweepy/client.py @@ -21,8 +21,8 @@ import requests import tweepy from tweepy.auth import OAuth1UserHandler from tweepy.errors import ( - BadRequest, Forbidden, HTTPException, TooManyRequests, TwitterServerError, - Unauthorized + BadRequest, Forbidden, HTTPException, NotFound, TooManyRequests, + TwitterServerError, Unauthorized ) from tweepy.list import List from tweepy.media import Media @@ -97,7 +97,8 @@ class BaseClient: raise Unauthorized(response) if response.status_code == 403: raise Forbidden(response) - # Handle 404? + if response.status_code == 404: + raise NotFound(response) if response.status_code == 429: if self.wait_on_rate_limit: reset_time = int(response.headers["x-rate-limit-reset"])