From 942b8b91f338f754ad047002530b2e93be0c357c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 13 Feb 2018 19:22:20 -0500 Subject: [PATCH] Simplify error logging in translator architecture Hopefully the previous stuff is no longer necessary --- .../zotero/xpcom/translation/translate.js | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index 2f617903e9..ef20c52313 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -1929,29 +1929,21 @@ Zotero.Translate.Base.prototype = { * Generates a string from an exception * @param {String|Exception} error */ - "_generateErrorString":function(error) { - var errorString = ""; - if(typeof(error) == "string") { - errorString = "\nthrown exception => "+error; - } else { - var haveStack = false; - for(var i in error) { - if(typeof(error[i]) != "object") { - if(i === "stack") haveStack = true; - errorString += "\n"+i+' => '+error[i]; - } - } - errorString += "\nstring => "+error.toString(); - if(!haveStack && error.stack) { - // In case the stack is not enumerable - errorString += "\nstack => "+error.stack.toString(); - } + _generateErrorString: function (error) { + var errorString = error; + if (error.stack && error) { + errorString += "\n\n" + error.stack; } - - errorString += "\nurl => "+this.path - + "\ndownloadAssociatedFiles => "+Zotero.Prefs.get("downloadAssociatedFiles") - + "\nautomaticSnapshots => "+Zotero.Prefs.get("automaticSnapshots"); - return errorString.substr(1); + if (this.path) { + errorString += `\nurl => ${this.path}`; + } + if (Zotero.Prefs.get("downloadAssociatedFiles")) { + errorString += "\ndownloadAssociatedFiles => true"; + } + if (Zotero.Prefs.get("automaticSnapshots")) { + errorString += "\nautomaticSnapshots => true"; + } + return errorString; }, /**