Skip to content

Commit

Permalink
Pass failure response to Connector.callMethod callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
adomasven committed Dec 14, 2016
1 parent deb8503 commit cff7448
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions chrome/content/zotero/xpcom/connector/connector.js
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit cff7448

Please sign in to comment.