MISC: Add source map to transformed scripts (#1812)

* MISC: Add source map to transformed scripts

* Print error to console
This commit is contained in:
catloversg
2025-01-20 04:50:50 +07:00
committed by GitHub
parent 7b009991e5
commit 9920b6ae4d
5 changed files with 52 additions and 11 deletions
+13 -1
View File
@@ -18,7 +18,19 @@ export function handleUnknownError(e: unknown, ws: WorkerScript | null = null, i
e = ws ? basicErrorMessage(ws, msg, "SYNTAX") : `SYNTAX ERROR:\n\n${msg}`;
} else if (e instanceof Error) {
// Ignore any cancellation errors from Monaco that get here
if (e.name === "Canceled" && e.message === "Canceled") return;
if (e.name === "Canceled" && e.message === "Canceled") {
return;
}
if (ws) {
console.error(`An error was thrown in your script. Hostname: ${ws.hostname}, script name: ${ws.name}.`);
}
/**
* If e is an instance of Error, we print it to the console. This is especially useful when debugging a TypeScript
* script. The stack trace in the error popup contains only the trace of the transpiled code. Even with a source
* map, parsing it to get the relevant info from the original TypeScript file is complicated. The built-in developer
* tool of browsers will do that for us if we print the error to the console.
*/
console.error(e);
const msg = getErrorMessageWithStackAndCause(e);
e = ws ? basicErrorMessage(ws, msg) : `RUNTIME ERROR:\n\n${msg}`;
}