From d4155488e1f65bc99feeaa028d8f21dd30ea9593 Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Wed, 26 Mar 2025 17:07:59 -0700 Subject: [PATCH] log stringified exceptions in debug output If an exception (e.g. Zotero.Exception.UnloadedDataException) is thrown without the debugger enabled (meaning, by most users), it is logged as a non-descriptive [JavaScript Error: "uncaught exception: Object"]. This stringifies the exception object and puts the string into the message, so that the actual error and the stacktrace are not lost. --- chrome/content/zotero/xpcom/zotero.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 4efd3b8cf3..b30bc2f986 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1373,7 +1373,12 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); } if (asStrings) { - errors.push(altMessage || msg.message) + let message = altMessage || msg.message; + // Stringify exceptions object instead of just returning "Object" + if (message.includes('uncaught exception: Object') && typeof msg.exception == "object") { + message = "[JavaScript Error:" + JSON.stringify(msg.exception); + } + errors.push(message); } else { errors.push(msg);