From 019635e5238e1db84fa7d75eec2c52d3e85d1c19 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 3 Dec 2024 20:15:30 -0800 Subject: [PATCH] alert on stack trace --- TODO.txt | 2 +- src/client/GameRunner.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/TODO.txt b/TODO.txt index 3a473dceb..b4467f2d8 100644 --- a/TODO.txt +++ b/TODO.txt @@ -206,9 +206,9 @@ * bugfix: when trade ships captured don't render DONE 12/3/2024 * use mini A* for all pathfinding DONE 12/3/2024 * bugfix: gameStop not found error DONE 12/3/2024 +* log stack traces & display them on screen DONE 12/3/2024 * record and replay games for debugging purposes * bugfix: destroyers can't find path to dst and freeze -* log stack traces & display them on screen * record single player game stats * add radiation from nuke * add cities diff --git a/src/client/GameRunner.ts b/src/client/GameRunner.ts index fc6e82d19..d489ebab9 100644 --- a/src/client/GameRunner.ts +++ b/src/client/GameRunner.ts @@ -173,7 +173,14 @@ export class GameRunner { } this.isProcessingTurn = true this.gs.addExecution(...this.executor.createExecs(this.turns[this.currTurn])) - this.gs.executeNextTick() + try { + this.gs.executeNextTick() + throw Error("test") + } catch (error) { + const errorText = `Error: ${error.message}\nStack: ${error.stack}`; + alert("Game crashed! Error info copied to clipboard. Please paste this in your bug report in Discord."); + navigator.clipboard.writeText(errorText); + } this.renderer.tick() this.currTurn++ this.isProcessingTurn = false