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

index 19bc84bab3b1e3e7e277d477b4b68e9f70c63df2..3082f76ff86396c161fc14fe546bc29ba030184a 100644 (file)
@@ -15,7 +15,7 @@ from tweepy.cache import Cache, FileCache, MemoryCache
 from tweepy.cursor import Cursor
 from tweepy.errors import (
     BadRequest, Forbidden, HTTPException, NotFound, TooManyRequests,
-    TweepyException, Unauthorized
+    TweepyException, TwitterServerError, Unauthorized
 )
 from tweepy.models import (
     DirectMessage, Friendship, ModelFactory, SavedSearch, SearchResults,
index f5f8b98132031f18aee418b80ae6d0e52804b09e..4855c94f45162ef26589e0fa0f60ebae005057e4 100644 (file)
@@ -14,7 +14,7 @@ import requests
 
 from tweepy.errors import (
     BadRequest, Forbidden, HTTPException, NotFound, TooManyRequests,
-    TweepyException, Unauthorized
+    TweepyException, TwitterServerError, Unauthorized
 )
 from tweepy.models import Model
 from tweepy.parsers import ModelParser, Parser
@@ -221,6 +221,8 @@ class API:
                 raise NotFound(resp)
             if resp.status_code == 429:
                 raise TooManyRequests(resp)
+            if resp.status_code >= 500:
+                raise TwitterServerError(resp)
             if resp.status_code and not 200 <= resp.status_code < 300:
                 raise HTTPException(resp)
 
index 5ae2bb26c8fb565921f2d68d7b3e562432c7bc11..1ddaff60fe941398c5aea11a01b0b5ddd135d977 100644 (file)
@@ -66,3 +66,7 @@ class NotFound(HTTPException):
 class TooManyRequests(HTTPException):
     """Exception raised for a 429 HTTP status code"""
     pass
+
+
+class TwitterServerError(HTTPException):
+    """Exception raised for a 5xx HTTP status code"""