Add Forbidden
authorHarmon <Harmon758@gmail.com>
Sun, 4 Apr 2021 14:06:12 +0000 (09:06 -0500)
committerHarmon <Harmon758@gmail.com>
Sun, 4 Apr 2021 14:06:12 +0000 (09:06 -0500)
tweepy/__init__.py
tweepy/api.py
tweepy/errors.py

index 64c0dcf15d23d3d61513406be899b1023472e731..f08249f30585f6ba84f29204a6814d8c0985b4d9 100644 (file)
@@ -14,7 +14,8 @@ from tweepy.auth import AppAuthHandler, OAuthHandler
 from tweepy.cache import Cache, FileCache, MemoryCache
 from tweepy.cursor import Cursor
 from tweepy.errors import (
-    HTTPException, NotFound, TooManyRequests, TweepyException, Unauthorized
+    Forbidden, HTTPException, NotFound, TooManyRequests, TweepyException,
+    Unauthorized
 )
 from tweepy.models import (
     DirectMessage, Friendship, ModelFactory, SavedSearch, SearchResults,
index acaef20ac7ff616d5350764775aa7ad5ae9ea470..7557991c580842bd052fdd1d13dfde2949550e0d 100644 (file)
@@ -13,7 +13,8 @@ from urllib.parse import urlencode
 import requests
 
 from tweepy.errors import (
-    HTTPException, NotFound, TooManyRequests, TweepyException, Unauthorized
+    Forbidden, HTTPException, NotFound, TooManyRequests, TweepyException,
+    Unauthorized
 )
 from tweepy.models import Model
 from tweepy.parsers import ModelParser, Parser
@@ -212,6 +213,8 @@ class API:
             self.last_response = resp
             if resp.status_code == 401:
                 raise Unauthorized(resp)
+            if resp.status_code == 403:
+                raise Forbidden(resp)
             if resp.status_code == 404:
                 raise NotFound(resp)
             if resp.status_code == 429:
index f27a6377cf399b502ecbded2b21cb3f6a365b4a3..e241796eb794f72a9386c19e2c8d4d68ece63c38 100644 (file)
@@ -48,6 +48,11 @@ class Unauthorized(HTTPException):
     pass
 
 
+class Forbidden(HTTPException):
+    """Exception raised for a 403 HTTP status code"""
+    pass
+
+
 class NotFound(HTTPException):
     """Exception raised for a 404 HTTP status code"""
     pass