aurelia-breeze
aurelia-breeze copied to clipboard
errorCallback from breeze manager.ExecuteQuery not executed
If I call an API (which throws an exception) using breeze's executeQuery method, the errorCallback function is never called.
var eq = new breeze.EntityQuery('TestError'); instance.manager.executeQuery( eq, function(data) { console.log('success') }, function(err) { debugger; });
this is api method
[HttpGet] public void TestError() { throw new Exception("test exception"); }
nor does it work with what is described here (see executeQuery method)
I suppose this is because aurelia-breeze replaces Q with ES6 Promises. Is it possible to have the errorCallback called anyway? Or am I just doing something wrong?
I am not sure if this has to do with this issue: https://github.com/jdanyow/aurelia-breeze/issues/44 If so, please feel free to remove this issue.
I think I solved it. I have added an extra catch block
requestInfo.config.request.fetch(config.url, init).then(function (response) {
response.json().then(function (data) {
var breezeResponse = new HttpResponse(response.status, data, response.headers, requestInfo.zConfig);
if (response.ok) {
requestInfo.success(breezeResponse);
} else {
requestInfo.error(breezeResponse);
}
})**.catch(function (error) { //new catch block
return requestInfo.error(error);
});**
}).catch(function (error) {
return requestInfo.error(error);
});
Now my errorCallback method is hit correctly. I could not inspect the .json method though as it was telling me "native code".
Missed this earlier, but it appears to be the same as my #44. In addition my reinstated code includes error.json processing.