diff --git a/command_logic/logic_gameplay.py b/command_logic/logic_gameplay.py index 55f2532..0144133 100644 --- a/command_logic/logic_gameplay.py +++ b/command_logic/logic_gameplay.py @@ -4295,12 +4295,14 @@ async def complete_game( else this_game.away_team ) + db_game = None try: db_game = await db_post("games", payload=game_data) db_ready_plays = get_db_ready_plays(session, this_game, db_game["id"]) db_ready_decisions = get_db_ready_decisions(session, this_game, db_game["id"]) except Exception as e: - await roll_back(db_game["id"]) + if db_game is not None: + await roll_back(db_game["id"]) log_exception(e, msg="Unable to post game to API, rolling back") # Post game stats to API