add stack trace for syntax errors

This commit is contained in:
Reimar 2025-10-16 09:54:24 +02:00
parent a0e983d5c3
commit d2a746cbe4
2 changed files with 6 additions and 0 deletions

View File

@ -31,6 +31,12 @@ export class CodeRunner {
const module = await import(`data:text/javascript;charset=utf-8,${encodedText}`);
this.evalScope = Object.assign(this.evalScope, module);
} catch (error) {
Error.captureStackTrace(error, this.run);
if (!error.stack || error instanceof SyntaxError) {
error.stack = `${error.fileName}:${error.lineNumber}:${error.columnNumber}`;
}
this.console.error(error);
}
}

0
src/gamelib_adapter.js Normal file
View File