Angular.js: angular 1.6.1 - $resource: no exception in console

Created on 19 Jan 2017  路  2Comments  路  Source: angular/angular.js

Do you want to request a feature or report a bug?
bug

What is the current behavior?
No error message is output in the console

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem:

No error message is output in the console:

var User = $resource('users/:id', {id: '@id'});
var user User.get({id: 123}, function (res) {
    y  = x + z; // this line not log any exception on the console
}, function () {
    console.log(arguments);
});

Error message is output in the console:

var User = $resource('users/:id', {id: '@id'});
var user User.get({id: 123}, function (res) {
    y  = x + z; // and this log the exception in the console
});

What is the expected behavior?
Exception output in the console in both cases

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.

Angular: 1.6.1
Chrome: 55.0.2883.87

PRs plz! ngResource low confusing bug

Most helpful comment

All 2 comments

Argh! It's a valid issue. We are silencing Possibly Unhandled Rejection errors if an error callback is provided, but this will incorrectly silence errors in the success callback, which are never passed to the error callback.

The success/error callbacks are messy anyway and I would like to deprecate them. It is much better to use "proper" promise methods:

var user User.get({id: 123});
user.$promise.then(onSuccess, onError);
// or even
// user.$promise.then(onSuccess).catch(onError);

#

In the meantime, we should fix this 馃槥

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brijesh1ec picture brijesh1ec  路  3Comments

ceymard picture ceymard  路  3Comments

nosideeffects picture nosideeffects  路  3Comments

landed1 picture landed1  路  3Comments

tdumitrescu picture tdumitrescu  路  3Comments