mirror of https://github.com/perkeep/perkeep.git
ui: deal better with unexpected non JSON responses
Change-Id: Ieacac4dc734421743ca30bf79b0f3afdbbe00892
This commit is contained in:
parent
9fcb4b6434
commit
489c78746b
|
@ -110,7 +110,15 @@ function(success, fail, e) {
|
||||||
var error = !xhr.isSuccess();
|
var error = !xhr.isSuccess();
|
||||||
var result = null;
|
var result = null;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
try {
|
||||||
result = xhr.getResponseJson();
|
result = xhr.getResponseJson();
|
||||||
|
} catch(err) {
|
||||||
|
console.log("Response was not valid JSON: " + xhr.getResponseText());
|
||||||
|
if (fail) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
error = !result;
|
error = !result;
|
||||||
}
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -154,7 +162,9 @@ function(success, opt_fail) {
|
||||||
|
|
||||||
this.sendXhr_(path,
|
this.sendXhr_(path,
|
||||||
goog.bind(this.handleXhrResponseJson_, this,
|
goog.bind(this.handleXhrResponseJson_, this,
|
||||||
success, this.safeFail_(opt_fail)
|
success, function(msg) {
|
||||||
|
console.log("serverStatus error: " + msg);
|
||||||
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue