From 933cccf4a0a61b211775b89d3f356739b236639f Mon Sep 17 00:00:00 2001 From: EvieePy <29671945+EvieePy@users.noreply.github.com> Date: Sun, 5 Jan 2025 09:06:26 +1000 Subject: [PATCH] Replace exceptions with HTTPExceptions --- twitchio/http.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/twitchio/http.py b/twitchio/http.py index a0336879..777f4332 100644 --- a/twitchio/http.py +++ b/twitchio/http.py @@ -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: @@ -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