Skip to content

Commit

Permalink
Improve exceptions raised for unknown method return types for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Harmon758 committed Oct 27, 2022
1 parent 381bf91 commit 3874579
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tweepy/asynchronous/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ async def __anext__(self):
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")
Expand Down
5 changes: 3 additions & 2 deletions tweepy/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ def __next__(self):
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")
Expand Down

0 comments on commit 3874579

Please sign in to comment.