From 542584eed30f4859996b8d674dd53955851791eb Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 13 Feb 2018 19:05:02 -0500 Subject: [PATCH] Make no-results error for search translation available as a property This allows translation-server to return a specific error code when there were no results. Also clarify the debug logging for search translation. --- chrome/content/zotero/xpcom/translation/translate.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index 87163d91c3..2f617903e9 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -2587,6 +2587,7 @@ Zotero.Translate.Search.prototype = new Zotero.Translate.Base(); Zotero.Translate.Search.prototype.type = "search"; Zotero.Translate.Search.prototype._entryFunctionSuffix = "Search"; Zotero.Translate.Search.prototype.Sandbox = Zotero.Translate.Sandbox._inheritFromBase(Zotero.Translate.Sandbox.Search); +Zotero.Translate.Search.prototype.ERROR_NO_RESULTS = "No items returned from any translator"; /** * @borrows Zotero.Translate.Web#setCookieSandbox @@ -2664,7 +2665,8 @@ Zotero.Translate.Search.prototype.complete = function(returnValue, error) { && !this._savingItems //length is 0 only when translate was called without translators && this.translator.length) { - Zotero.debug("Translate: Could not find a result using "+this.translator[0].label, 3); + Zotero.debug("Translate: Could not find a result using " + this.translator[0].label + + (this.translator.length > 1 ? " -- trying next translator" : ""), 3); if(error) Zotero.debug(this._generateErrorString(error), 3); if(this.translator.length > 1) { this.translator.shift(); @@ -2675,7 +2677,8 @@ Zotero.Translate.Search.prototype.complete = function(returnValue, error) { }); return; } else { - error = "No items returned from any translator"; + Zotero.debug("No more translators to try"); + error = this.ERROR_NO_RESULTS; returnValue = false; } }