mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 13:57:05 +02:00
unified errors
This commit is contained in:
+3
-12
@@ -24,7 +24,7 @@ import { Settings } from "./Settings/Settings";
|
||||
|
||||
import { generate } from "escodegen";
|
||||
|
||||
import { dialogBoxCreate, errorDialog } from "./ui/React/DialogBox";
|
||||
import { dialogBoxCreate } from "./ui/React/DialogBox";
|
||||
import { arrayToString } from "./utils/helpers/arrayToString";
|
||||
import { roundToTwo } from "./utils/helpers/roundToTwo";
|
||||
|
||||
@@ -33,7 +33,7 @@ import { simple as walksimple } from "acorn-walk";
|
||||
import { areFilesEqual } from "./Terminal/DirectoryHelpers";
|
||||
import { Terminal } from "./Terminal";
|
||||
import { ScriptArg } from "./Netscript/ScriptArg";
|
||||
import { helpers } from "./Netscript/NetscriptHelpers";
|
||||
import { handleUnknownError } from "./Netscript/NetscriptHelpers";
|
||||
|
||||
export const NetscriptPorts: Map<number, IPort> = new Map();
|
||||
|
||||
@@ -347,16 +347,7 @@ function createAndAddWorkerScript(runningScriptObj: RunningScript, server: BaseS
|
||||
workerScript.log("", () => "Script finished running");
|
||||
})
|
||||
.catch(function (e) {
|
||||
if (typeof e === "string") {
|
||||
const headerText = helpers.makeBasicErrorMsg(workerScript, "", "");
|
||||
//Add header info if it is not present;
|
||||
if (!e.includes(headerText)) e = helpers.makeBasicErrorMsg(workerScript, e);
|
||||
} else if (e instanceof SyntaxError) {
|
||||
e = helpers.makeBasicErrorMsg(workerScript, `${e.message} (sorry we can't be more helpful)`, "SYNTAX");
|
||||
} else if (e instanceof Error) {
|
||||
e = helpers.makeBasicErrorMsg(workerScript, `${e.message}${e.stack ? `\nstack:\n${e.stack.toString()}` : ""}`);
|
||||
}
|
||||
errorDialog(e);
|
||||
handleUnknownError(e, workerScript);
|
||||
workerScript.log("", () => (e instanceof ScriptDeath ? "Script killed." : "Script crashed due to an error."));
|
||||
killWorkerScript(workerScript);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user