Unify error handling

This commit is contained in:
Snarling
2022-08-28 05:33:38 -04:00
parent 8dd507883a
commit 5798c4c7d3
21 changed files with 149 additions and 324 deletions
+5 -4
View File
@@ -71,7 +71,7 @@ export async function executeJSScript(
const ns = workerScript.env.vars;
if (!loadedModule) {
throw helpers.makeRuntimeRejectMsg(
throw helpers.makeBasicErrorMsg(
workerScript,
`${script.filename} cannot be run because the script module won't load`,
);
@@ -79,18 +79,19 @@ export async function executeJSScript(
// TODO: putting await in a non-async function yields unhelpful
// "SyntaxError: unexpected reserved word" with no line number information.
if (!loadedModule.main) {
throw helpers.makeRuntimeRejectMsg(
throw helpers.makeBasicErrorMsg(
workerScript,
`${script.filename} cannot be run because it does not have a main function.`,
);
}
if (!ns) {
throw helpers.makeRuntimeRejectMsg(
throw helpers.makeBasicErrorMsg(
workerScript,
`${script.filename} cannot be run because the NS object hasn't been constructed properly.`,
);
}
return loadedModule.main(ns);
await loadedModule.main(ns);
return;
}
function isDependencyOutOfDate(filename: string, scripts: Script[], scriptModuleSequenceNumber: number): boolean {