aboutsummaryrefslogtreecommitdiff
path: root/src/js/_codegen/client-js.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/_codegen/client-js.ts')
-rw-r--r--src/js/_codegen/client-js.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/js/_codegen/client-js.ts b/src/js/_codegen/client-js.ts
index 2db3305fa..bd9ed63f4 100644
--- a/src/js/_codegen/client-js.ts
+++ b/src/js/_codegen/client-js.ts
@@ -27,10 +27,18 @@ export function createAssertClientJS(publicName: string) {
return `
let $assert = function(check, sourceString, ...message) {
if (!check) {
- console.error('[${publicName}] ASSERTION FAILED: ' + sourceString);
- if(message.length)console.warn (' ${" ".repeat(publicName.length)}', ...message);
+ const prevPrepareStackTrace = Error.prepareStackTrace;
+ Error.prepareStackTrace = (e, stack) => {
+ return e.name + ': ' + e.message + '\\n' + stack.slice(1).map(x => ' at ' + x.toString()).join('\\n');
+ };
const e = new Error(sourceString);
+ e.stack; // materialize stack
e.name = 'AssertionError';
+ Error.prepareStackTrace = prevPrepareStackTrace;
+ console.error('[${publicName}] ASSERTION FAILED: ' + sourceString);
+ if (message.length) console.warn(...message);
+ console.warn(e.stack.split('\\n')[1] + '\\n');
+ if (Bun.env.ASSERT === 'CRASH') process.exit(0xAA);
throw e;
}
}