check_game: handle error if game is not in DB

This commit is contained in:
Maximilian Keßler 2023-05-14 19:10:41 +02:00
parent fb713fcf9e
commit 217d5b4a82
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -22,7 +22,10 @@ def check_game(game_id: int) -> Tuple[int, GameState]:
"WHERE games.id = (%s)", "WHERE games.id = (%s)",
(game_id,) (game_id,)
) )
(num_players, compressed_deck, compressed_actions, score, variant_id) = cur.fetchone() res = cur.fetchone()
if res is None:
raise ValueError("No game associated with id {} in database.".format(game_id))
(num_players, compressed_deck, compressed_actions, score, variant_id) = res
deck = decompress_deck(compressed_deck) deck = decompress_deck(compressed_deck)
actions = decompress_actions(compressed_actions) actions = decompress_actions(compressed_actions)