www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit cff74484be160406de70023112dd67647a555e2f
parent deb85038634ac6f99bc7811164c8b090880e71a6
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date:   Wed, 14 Dec 2016 16:02:37 +0200

Pass failure response to Connector.callMethod callbacks

Diffstat:
Mchrome/content/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 @@ -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) {