IPVGO: Improve error logging to include stacktraces (#1212)

This commit is contained in:
Michael Ficocelli 2024-04-09 09:36:05 -04:00 committed by GitHub
parent 1ad6f9f310
commit 057ccc2a2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 10 deletions

@ -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
*/

@ -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