From e43b1b07f0a68ea91760e40043249ef0693479a0 Mon Sep 17 00:00:00 2001 From: Grace Kind Date: Sat, 18 Jul 2026 19:26:10 -0500 Subject: [PATCH] Improve dev logging --- src/js/errorLogs.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/js/errorLogs.js b/src/js/errorLogs.js index cb7b0b2f..2fac999e 100644 --- a/src/js/errorLogs.js +++ b/src/js/errorLogs.js @@ -15,8 +15,10 @@ function formatArg(arg) { if (typeof arg === "string") { return arg; } - if (arg instanceof Error) { - return arg.stack ?? String(arg); + if (arg instanceof Error || arg?.message || arg?.stack) { + const message = arg.message ?? String(arg); + const stack = arg.stack ?? ""; + return stack.includes(message) ? stack : `${message}\n${stack}`; } try { return JSON.stringify(arg); @@ -65,6 +67,10 @@ export function enableErrorLogs() { } window.addEventListener("error", (event) => { + const file = event.filename || ""; + if (!file.startsWith(location.origin)) { + return; // probably browser or extension code + } showMessage(`${event.message} at ${event.filename}:${event.lineno}`); }); window.addEventListener("unhandledrejection", (event) => { -- 2.51.2