mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-23 14:42:28 +01:00
dialogBox+stop on NS1 async function throw
This commit is contained in:
parent
91841836c9
commit
7ec1ced729
@ -178,7 +178,7 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
|
|||||||
const entry = ns[name];
|
const entry = ns[name];
|
||||||
if (typeof entry === "function") {
|
if (typeof entry === "function") {
|
||||||
//Async functions need to be wrapped. See JS-Interpreter documentation
|
//Async functions need to be wrapped. See JS-Interpreter documentation
|
||||||
if (["hack", "grow", "weaken", "sleep", "prompt", "manualHack", "scp", "write", "share"].includes(name)) {
|
if (["hack", "grow", "weaken", "sleep", "prompt", "manualHack", "scp", "write", "share", "wget"].includes(name)) {
|
||||||
const tempWrapper = function (...args: any[]): void {
|
const tempWrapper = function (...args: any[]): void {
|
||||||
const fnArgs = [];
|
const fnArgs = [];
|
||||||
|
|
||||||
@ -199,7 +199,21 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
|
|||||||
})
|
})
|
||||||
.catch(function (err: any) {
|
.catch(function (err: any) {
|
||||||
// workerscript is when you cancel a delay
|
// workerscript is when you cancel a delay
|
||||||
if (!(err instanceof WorkerScript)) console.error(err);
|
if (!(err instanceof WorkerScript)) {
|
||||||
|
console.error(err);
|
||||||
|
const errorTextArray = err.split("|DELIMITER|");
|
||||||
|
const hostname = errorTextArray[1];
|
||||||
|
const scriptName = errorTextArray[2];
|
||||||
|
const errorMsg = errorTextArray[3];
|
||||||
|
let msg = `${scriptName}@${hostname}<br>`;
|
||||||
|
msg += "<br>";
|
||||||
|
msg += errorMsg;
|
||||||
|
dialogBoxCreate(msg);
|
||||||
|
workerScript.env.stopFlag = true;
|
||||||
|
workerScript.running = false;
|
||||||
|
killWorkerScript(workerScript);
|
||||||
|
return Promise.resolve(workerScript);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
int.setProperty(scope, name, int.createAsyncFunction(tempWrapper));
|
int.setProperty(scope, name, int.createAsyncFunction(tempWrapper));
|
||||||
|
Loading…
Reference in New Issue
Block a user