Add exception-catchers that point out exactly which game or channel causes a crash
This commit is contained in:
1 parent
dbd3cd82a0
commit
a536dde677
2 files changed
+6
No files matched your search
@@ -244,9 +244,12 @@ class Channel:
|
|||||||
return URLType(match.group(1))
|
return URLType(match.group(1))
|
||||||
|
|
||||||
async def get_stream(self) -> Stream | None:
|
async def get_stream(self) -> Stream | None:
|
||||||
|
try:
|
||||||
response: JsonType = await self._twitch.gql_request(
|
response: JsonType = await self._twitch.gql_request(
|
||||||
GQL_OPERATIONS["GetStreamInfo"].with_variables({"channel": self._login})
|
GQL_OPERATIONS["GetStreamInfo"].with_variables({"channel": self._login})
|
||||||
)
|
)
|
||||||
|
except MinerException as exc:
|
||||||
|
raise MinerException(f"Channel: {self._login}") from exc
|
||||||
stream_data: JsonType | None = response["data"]["user"]
|
stream_data: JsonType | None = response["data"]["user"]
|
||||||
if not stream_data:
|
if not stream_data:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -1710,6 +1710,7 @@ class Twitch:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
async def get_live_streams(self, game: Game, *, limit: int = 30) -> list[Channel]:
|
async def get_live_streams(self, game: Game, *, limit: int = 30) -> list[Channel]:
|
||||||
|
try:
|
||||||
response = await self.gql_request(
|
response = await self.gql_request(
|
||||||
GQL_OPERATIONS["GameDirectory"].with_variables({
|
GQL_OPERATIONS["GameDirectory"].with_variables({
|
||||||
"limit": limit,
|
"limit": limit,
|
||||||
@@ -1720,6 +1721,8 @@ class Twitch:
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
except MinerException as exc:
|
||||||
|
raise MinerException(f"Game: {game.slug}") from exc
|
||||||
if "game" in response["data"]:
|
if "game" in response["data"]:
|
||||||
return [
|
return [
|
||||||
Channel.from_directory(self, stream_channel_data["node"], drops_enabled=True)
|
Channel.from_directory(self, stream_channel_data["node"], drops_enabled=True)
|
||||||
|
|||||||
Reference in new issue
Block a user