From b6b82196d3f0821c184901de985e2cedb56a9db2 Mon Sep 17 00:00:00 2001 From: Harmon Date: Thu, 24 Mar 2022 01:18:30 -0500 Subject: [PATCH] Raise NotFound when encountering 404 status codes in BaseClient.request Raise NotFound rather than HTTPException when encountering 404 response status codes in BaseClient.request --- tweepy/client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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"]) -- 2.25.1