aurelia-breeze icon indicating copy to clipboard operation
aurelia-breeze copied to clipboard

errorCallback from breeze manager.ExecuteQuery not executed

Open mirkolugano opened this issue 7 years ago • 2 comments

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.

mirkolugano avatar Mar 07 '17 09:03 mirkolugano

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".

mirkolugano avatar Mar 29 '17 12:03 mirkolugano

Missed this earlier, but it appears to be the same as my #44. In addition my reinstated code includes error.json processing.

rockResolve avatar Nov 29 '18 23:11 rockResolve