From cac1f0255770d6181d38e87c35a40279ee6d6dad Mon Sep 17 00:00:00 2001 From: Zutatensuppe Date: Thu, 24 Dec 2020 15:09:57 +0100 Subject: [PATCH] throw exceptions when game/gamelog doesnt exist --- server/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/index.js b/server/index.js index 736d116..ad9197f 100644 --- a/server/index.js +++ b/server/index.js @@ -140,6 +140,9 @@ wss.on('message', async ({socket, data}) => { const msgType = msg[0] switch (msgType) { case Protocol.EV_CLIENT_INIT_REPLAY: { + if (!GameLog.exists(gameId)) { + throw `[gamelog ${gameId} does not exist... ]` + } const log = GameLog.get(gameId) let game = await Game.createGameObject( gameId, @@ -186,6 +189,9 @@ wss.on('message', async ({socket, data}) => { } break; case Protocol.EV_CLIENT_EVENT: { + if (!Game.exists(gameId)) { + throw `[game ${gameId} does not exist... ]` + } const clientSeq = msg[1] const clientEvtData = msg[2] const ts = Util.timestamp()