Pass failure response to Connector.callMethod callbacks
This commit is contained in:
parent
deb8503863
commit
cff74484be
1 changed files with 9 additions and 10 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue