Skip to content

Commit

Permalink
Add exception-catchers that point out exactly which game or channel c…
Browse files Browse the repository at this point in the history
…auses a crash
  • Loading branch information
DevilXD committed Feb 17, 2024
1 parent dbd3cd8 commit a536dde
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
9 changes: 6 additions & 3 deletions channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,12 @@ async def get_spade_url(self) -> URLType:
return URLType(match.group(1))

async def get_stream(self) -> Stream | None:
response: JsonType = await self._twitch.gql_request(
GQL_OPERATIONS["GetStreamInfo"].with_variables({"channel": self._login})
)
try:
response: JsonType = await self._twitch.gql_request(
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"]
if not stream_data:
return None
Expand Down
23 changes: 13 additions & 10 deletions twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1710,16 +1710,19 @@ def get_active_drop(self, channel: Channel | None = None) -> TimedDrop | None:
return None

async def get_live_streams(self, game: Game, *, limit: int = 30) -> list[Channel]:
response = await self.gql_request(
GQL_OPERATIONS["GameDirectory"].with_variables({
"limit": limit,
"slug": game.slug,
"options": {
"includeRestricted": ["SUB_ONLY_LIVE"],
"systemFilters": ["DROPS_ENABLED"],
},
})
)
try:
response = await self.gql_request(
GQL_OPERATIONS["GameDirectory"].with_variables({
"limit": limit,
"slug": game.slug,
"options": {
"includeRestricted": ["SUB_ONLY_LIVE"],
"systemFilters": ["DROPS_ENABLED"],
},
})
)
except MinerException as exc:
raise MinerException(f"Game: {game.slug}") from exc
if "game" in response["data"]:
return [
Channel.from_directory(self, stream_channel_data["node"], drops_enabled=True)
Expand Down

0 comments on commit a536dde

Please sign in to comment.