mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 09:42:53 +02:00
MISC: Add source map to transformed scripts (#1812)
* MISC: Add source map to transformed scripts * Print error to console
This commit is contained in:
@@ -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}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user