mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-08 03:24:48 +01:00
ns.atExit errors more readable, allows ns functions
This commit is contained in:
@ -52,22 +52,24 @@ function killWorkerScriptByPid(pid: number): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopAndCleanUpWorkerScript(workerScript: WorkerScript): void {
|
function stopAndCleanUpWorkerScript(ws: WorkerScript): void {
|
||||||
if (typeof workerScript.atExit === "function") {
|
killNetscriptDelay(ws);
|
||||||
|
if (typeof ws.atExit === "function") {
|
||||||
try {
|
try {
|
||||||
workerScript.atExit();
|
ws.env.stopFlag = false;
|
||||||
|
ws.atExit();
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
|
let message = e instanceof ScriptDeath ? e.errorMessage : String(e);
|
||||||
|
message = message.replace(/.*\|DELIMITER\|/, "");
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
`Error trying to call atExit for script ${workerScript.name} on ${workerScript.hostname} ${
|
`Error trying to call atExit for script ${ws.name} on ${ws.hostname} ${ws.scriptRef.args}\n` + message,
|
||||||
workerScript.scriptRef.args
|
|
||||||
} ${String(e)}`,
|
|
||||||
);
|
);
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
workerScript.atExit = undefined;
|
ws.atExit = undefined;
|
||||||
}
|
}
|
||||||
workerScript.env.stopFlag = true;
|
ws.env.stopFlag = true;
|
||||||
killNetscriptDelay(workerScript);
|
removeWorkerScript(ws);
|
||||||
removeWorkerScript(workerScript);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user