Improve exceptions raised for unknown method return types for pagination
authorHarmon <Harmon758@gmail.com>
Thu, 27 Oct 2022 17:56:10 +0000 (12:56 -0500)
committerHarmon <Harmon758@gmail.com>
Thu, 27 Oct 2022 17:56:10 +0000 (12:56 -0500)
tweepy/asynchronous/pagination.py
tweepy/pagination.py

index 6743e0b61d48bffe9a913096df4e783a2a1c0632..bd2d9c1a87d8603bdb5b3aceaa9067595ff72c1f 100644 (file)
@@ -128,8 +128,9 @@ class AsyncPaginationIterator:
         elif isinstance(response, aiohttp.ClientResponse):
             meta = (await response.json()).get("meta", {})
         else:
-            raise NotImplementedError(
-                f"Unknown {type(response)} return type for {self.method}"
+            raise RuntimeError(
+                f"Unknown {type(response)} return type for "
+                f"{self.method.__qualname__}"
             )
 
         self.previous_token = meta.get("previous_token")
index cdf429dae37c84bf0696504e71536e9c8e3f7bd7..b30c9e669deae3870bce71bde63ea80e2aa15109 100644 (file)
@@ -124,8 +124,9 @@ class PaginationIterator:
         elif isinstance(response, requests.Response):
             meta = response.json().get("meta", {})
         else:
-            raise NotImplementedError(
-                f"Unknown {type(response)} return type for {self.method}"
+            raise RuntimeError(
+                f"Unknown {type(response)} return type for "
+                f"{self.method.__qualname__}"
             )
 
         self.previous_token = meta.get("previous_token")