Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errorCallback from breeze manager.ExecuteQuery not executed #46

Open
mirkolugano opened this issue Mar 7, 2017 · 2 comments
Open

errorCallback from breeze manager.ExecuteQuery not executed #46

mirkolugano opened this issue Mar 7, 2017 · 2 comments

Comments

@mirkolugano
Copy link

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:
#44
If so, please feel free to remove this issue.

@mirkolugano
Copy link
Author

mirkolugano commented Mar 29, 2017

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

@rockResolve
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants