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 26988646bf)
This commit is contained in:
Dan Stillman 2026-09-08 14:00:21 -04:00
parent 9244cbe50a
commit 6d6510fec5

View file

@ -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;