I have code with AngularJS:
service.doSomething() .then(function(result) {
In AngularJS 1.5.9, when I have an error in the .then() section, for example:
service.doSomething() .then(function(result) { var x = null; var y = xy;
I get an error message:
TypeError: Unable to read property 'y' null
But in version 1.6 with the same code, I get another error:
Possible raw rejection: {} undefined
I know that this is due to this change , and one solution is quite simple by adding a .catch() block:
service.doSomething() .then(function(result) { var x = null; var y = xy;
Now I again have what I want:
TypeError: Unable to read property 'y' null
But how to get the same result (a more detailed error) for the entire application without adding the .catch() block in every place?
I tested the proposed solution to disable it by adding:
$qProvider.errorOnUnhandledRejections(false);
But with this the situation is even worse - I have NO ANYONE in the console! The error is swallowed somewhere and is not recorded at all. I'm not sure if this is a problem with AngularJS 1.6 or with my configuration.
Do you have any ideas on how to "restore" log behavior from version 1.5.9?
EDIT:
Adding a custom error handler:
.factory('$exceptionHandler', function($log) { return function(exception, cause) { $log.warn(exception, cause); }; })
doesn't help at all. In the error handler, I already got a wrapped error.