Skip to content

Commit

Permalink
Replace exceptions with HTTPExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
EvieePy committed Jan 4, 2025
1 parent b62f03a commit 933cccf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions twitchio/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ async def _call_next(self) -> None:
try:
inner: list[RawResponse] = data["data"] if self._nested_key is None else data["data"][self._nested_key]
except KeyError as e:
# TODO: Proper exception...
raise ValueError('Expected "data" key not found.') from e
raise HTTPException('Expected "data" key not found.', route=self._route, status=500, extra="") from e

if not self._nested_key:
for value in inner:
Expand Down Expand Up @@ -531,8 +530,7 @@ async def request_json(self, route: Route) -> Any:
data = await self.request(route)

if isinstance(data, str):
# TODO: Add a HTTPException here.
raise TypeError("Expected JSON data, but received text data.")
raise HTTPException("Expected JSON data, but received text data.", status=500, extra=data)

return data

Expand Down

0 comments on commit 933cccf

Please sign in to comment.