From 057ccc2a2b3d96015eadd02f52117fa0f62f7d39 Mon Sep 17 00:00:00 2001 From: Michael Ficocelli Date: Tue, 9 Apr 2024 09:36:05 -0400 Subject: [PATCH] IPVGO: Improve error logging to include stacktraces (#1212) --- src/Go/effects/netscriptGoImplementation.ts | 8 -------- src/NetscriptFunctions/Go.ts | 6 ++++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Go/effects/netscriptGoImplementation.ts b/src/Go/effects/netscriptGoImplementation.ts index 74d82535d..4aa3afa61 100644 --- a/src/Go/effects/netscriptGoImplementation.ts +++ b/src/Go/effects/netscriptGoImplementation.ts @@ -12,7 +12,6 @@ import { simpleBoardFromBoard, } from "../boardAnalysis/boardAnalysis"; import { getScore, resetWinstreak } from "../boardAnalysis/scoring"; -import { WorkerScript } from "../../Netscript/WorkerScript"; import { WHRNG } from "../../Casino/RNG"; /** @@ -437,13 +436,6 @@ export function cheatSuccessChance(cheatCount: number) { return Math.max(Math.min(0.6 * cheatCountScalar * Player.mults.crime_success + sourceFileBonus, 1), 0); } -/** - * Throw a runtime error that halts the player's script - */ -export function throwError(ws: WorkerScript, errorMessage: string) { - throw `RUNTIME ERROR\n${ws.name}@${ws.hostname} (PID - ${ws.pid})\n\n ${errorMessage}`; -} - /** * Attempts to remove an existing router from the board. Can fail. If failed, can immediately end the game */ diff --git a/src/NetscriptFunctions/Go.ts b/src/NetscriptFunctions/Go.ts index 12c98e033..b1d6809f6 100644 --- a/src/NetscriptFunctions/Go.ts +++ b/src/NetscriptFunctions/Go.ts @@ -22,14 +22,16 @@ import { handlePassTurn, makePlayerMove, resetBoardState, - throwError, validateMove, validateTurn, } from "../Go/effects/netscriptGoImplementation"; import { getEnumHelper } from "../utils/EnumHelper"; +import { errorMessage } from "../Netscript/ErrorMessages"; const logger = (ctx: NetscriptContext) => (message: string) => helpers.log(ctx, () => message); -const error = (ctx: NetscriptContext) => (message: string) => throwError(ctx.workerScript, message); +const error = (ctx: NetscriptContext) => (message: string) => { + throw errorMessage(ctx, message); +}; /** * Go API implementation