Try to make an error message more helpful

This commit is contained in:
Olivier Gagnon
2021-10-11 18:47:05 -04:00
parent 1ff7f4bcd4
commit faad0ae8a7
7 changed files with 67 additions and 59450 deletions
+8 -4
View File
@@ -124,10 +124,14 @@ function startNetscript2Script(workerScript: WorkerScript): Promise<WorkerScript
.catch((e) => reject(e));
}).catch((e) => {
if (e instanceof Error) {
workerScript.errorMessage = makeRuntimeRejectMsg(
workerScript,
e.message + ((e.stack && "\nstack:\n" + e.stack.toString()) || ""),
);
if (e instanceof SyntaxError) {
workerScript.errorMessage = makeRuntimeRejectMsg(workerScript, e.message + " (sorry we can't be more helpful)");
} else {
workerScript.errorMessage = makeRuntimeRejectMsg(
workerScript,
e.message + ((e.stack && "\nstack:\n" + e.stack.toString()) || ""),
);
}
throw workerScript;
} else if (isScriptErrorMessage(e)) {
workerScript.errorMessage = e;