From fff1de63d3f1863553eae8fbde53da9a66f8212f Mon Sep 17 00:00:00 2001 From: nickofolas Date: Mon, 3 Jan 2022 17:26:22 -0600 Subject: [PATCH] Fix throw (nullish) errors --- src/NetscriptEvaluator.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NetscriptEvaluator.ts b/src/NetscriptEvaluator.ts index dfba570f7..915bc6534 100644 --- a/src/NetscriptEvaluator.ts +++ b/src/NetscriptEvaluator.ts @@ -22,7 +22,8 @@ export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): s } for (const scriptUrl of workerScript.scriptRef.dependencies) { - msg = msg.replace(new RegExp(scriptUrl.url, "g"), scriptUrl.filename); + // Return just the original msg if it's nullish so that we don't get a workerscript error + msg = msg?.replace(new RegExp(scriptUrl.url, "g"), scriptUrl.filename) ?? msg; } return "|DELIMITER|" + server.hostname + "|DELIMITER|" + workerScript.name + "|DELIMITER|" + msg;