Skip to content

Commit

Permalink
Raise NotFound when encountering 404 status codes in BaseClient.request
Browse files Browse the repository at this point in the history
Raise NotFound rather than HTTPException when encountering 404 response status codes in BaseClient.request
  • Loading branch information
Harmon758 committed Mar 24, 2022
1 parent 3d311e6 commit b6b8219
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tweepy/client.py
Expand Up @@ -21,8 +21,8 @@
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
Expand Down Expand Up @@ -97,7 +97,8 @@ def request(self, method, route, params=None, json=None, user_auth=False):
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"])
Expand Down

0 comments on commit b6b8219

Please sign in to comment.