update on elasticsearch.js, handling on exception response [jquery]

This commit is contained in:
Jason.Wong
2018-02-09 15:53:55 +08:00
parent fac7741d7e
commit 07c803f9c5

View File

@ -33,7 +33,14 @@ JqueryConnector.prototype.request = function (params, cb) {
});
})
.fail(function (a, b, err) {
cb(new ConnectionFault(err && err.message));
// if response is available, execute cb. Else throw ConnectionFault
if (a && a.responseText) {
cb(null, a.responseText, jqXHR.statusCode(), {
'content-type': jqXHR.getResponseHeader('content-type')
});
} else {
cb(new ConnectionFault(err && err.message));
}
});
return function () {