From cff74484be160406de70023112dd67647a555e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Wed, 14 Dec 2016 16:02:37 +0200 Subject: [PATCH] Pass failure response to Connector.callMethod callbacks --- .../zotero/xpcom/connector/connector.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/xpcom/connector/connector.js b/chrome/content/zotero/xpcom/connector/connector.js index 0cc2c11d1c..065a752d9c 100644 --- a/chrome/content/zotero/xpcom/connector/connector.js +++ b/chrome/content/zotero/xpcom/connector/connector.js @@ -174,10 +174,17 @@ Zotero.Connector = new function() { Zotero.Connector_Browser.onStateChange(isOnline); } } - + var val = null; + if(req.responseText) { + if(req.getResponseHeader("Content-Type") === "application/json") { + val = JSON.parse(req.responseText); + } else { + val = req.responseText; + } + } if(req.status == 0 || req.status >= 400) { Zotero.debug("Connector: Method "+method+" failed with status "+req.status); - if(callback) callback(false, req.status); + if(callback) callback(false, req.status, val); // Check for incompatible version if(req.status === 412) { @@ -190,14 +197,6 @@ Zotero.Connector = new function() { } } else { Zotero.debug("Connector: Method "+method+" succeeded"); - var val = null; - if(req.responseText) { - if(req.getResponseHeader("Content-Type") === "application/json") { - val = JSON.parse(req.responseText); - } else { - val = req.responseText; - } - } if(callback) callback(val, req.status); } } catch(e) {