From 34e23937a158344a4dcb9ca3d89a580087226d89 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 5 Aug 2017 01:09:57 +0200 Subject: [PATCH] Remove pointless Bluebird lines from various stack traces --- chrome/content/zotero/xpcom/utilities.js | 5 +++-- chrome/content/zotero/xpcom/utilities_internal.js | 7 +++++++ chrome/content/zotero/xpcom/zotero.js | 9 ++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 872a3f5987..70ea26c5ff 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1446,14 +1446,15 @@ Zotero.Utilities = { let msg = (obj.message ? ('' + obj.message).replace(/^/gm, level_padding).trim() : ''); if (obj.stack) { let stack = obj.stack.trim().replace(/^(?=.)/gm, level_padding); + stack = Zotero.Utilities.Internal.filterStack(stack); msg += '\n\n'; // At least with Zotero.HTTP.UnexpectedStatusException, the stack contains "Error:" // and the message in addition to the trace. I'm not sure what's causing that // (Bluebird?), but fix it here. - if (obj.stack.startsWith('Error:')) { - msg += obj.stack.replace('Error: ' + obj.message + '\n', ''); + if (stack.startsWith('Error:')) { + msg += stack.replace('Error: ' + obj.message + '\n', ''); } else { msg += stack; diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index e8b9896e96..df74d48da8 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1123,6 +1123,13 @@ Zotero.Utilities.Internal = { }, + filterStack: function (stack) { + return stack.split(/\n/) + .filter(line => !line.includes('resource://zotero/bluebird')) + .join('\n'); + }, + + quitZotero: function(restart=false) { Zotero.debug("Zotero.Utilities.Internal.quitZotero() is deprecated -- use quit()"); this.quit(restart); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 3b695bdce0..ea74f4966a 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -768,8 +768,10 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); throw e; } - Zotero.startupError = Zotero.getString('startupError.databaseUpgradeError') + "\n\n" - + (e.stack || e); + let stack = e.stack ? Zotero.Utilities.Internal.filterStack(e.stack) : null; + Zotero.startupError = Zotero.getString('startupError.databaseUpgradeError') + + "\n\n" + + (stack || e); throw e; } @@ -899,7 +901,8 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); ); } else { - Zotero.startupError = Zotero.getString('startupError') + "\n\n" + (e.stack || e); + let stack = e.stack ? Zotero.Utilities.Internal.filterStack(e.stack) : null; + Zotero.startupError = Zotero.getString('startupError') + "\n\n" + (stack || e); } Zotero.debug(e.toString(), 1);