From 6d6510fec5a7acfea1da4115d533ad53edc57627 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 8 Sep 2026 14:00:21 -0400 Subject: [PATCH] Include the error message in startup error dialogs SpiderMonkey stacks contain only frames, so the startup error messages that showed just the stack didn't say what had failed. 9b3d7a32e3 added the message to one of the three, where a ternary-precedence bug then dropped the surrounding text instead. Format all three the same way. (cherry picked from commit 26988646bf8b85f1f943f297b742cb4a3186c669) --- chrome/content/zotero/xpcom/zotero.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 87f054e06c..31bc56d991 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -672,10 +672,9 @@ const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/conte // Report the error unless corruption recovery has already started a quit // or restart if (!Zotero.skipLoading) { - let stack = e.stack ? Zotero.Utilities.Internal.filterStack(e.stack) : null; Zotero.startupError = Zotero.getString('startupError.databaseUpgradeError') + "\n\n" - + (stack || e); + + _formatStartupError(e); } throw e; } @@ -856,7 +855,7 @@ const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/conte if (!Zotero.startupError && !Zotero.skipLoading) { Zotero.startupError = Zotero.getString('startupError', Zotero.appName) + "\n\n" + Zotero.getString('db.integrityCheck.reportInForums') + "\n\n" - + e.message ? (e.message + "\n\n" + e.stack) : e; + + _formatStartupError(e); } return false; } @@ -914,10 +913,9 @@ const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/conte Zotero.startupError = Zotero.getString('startupError.databaseInUse'); } else { - let stack = e.stack ? Zotero.Utilities.Internal.filterStack(e.stack) : null; Zotero.startupError = Zotero.getString('startupError', Zotero.appName) + "\n\n" + Zotero.getString('db.integrityCheck.reportInForums') + "\n\n" - + (stack || e); + + _formatStartupError(e); } Zotero.debug(e.toString(), 1); @@ -930,6 +928,20 @@ const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/conte }; + /** + * Format an error for a startup error message + * + * SpiderMonkey stacks contain only frames, so the message has to be included with them. + * + * @param {Error|*} e + * @return {String|*} + */ + function _formatStartupError(e) { + var stack = e.stack ? Zotero.Utilities.Internal.filterStack(e.stack) : null; + return [e.message, stack].filter(x => x).join("\n\n") || e; + } + + function _checkDataDirAccessError(e) { if (e.name != 'NS_ERROR_FILE_ACCESS_DENIED' && !e.message.includes('2152857621')) { return false;