angular-cache icon indicating copy to clipboard operation
angular-cache copied to clipboard

Unhandled promise rejection hidden within library

Open striche2 opened this issue 8 years ago • 2 comments

Since Angular 1.6, unhandled promise rejections are sent to the exceptionHandler. In cases where you don't want a rejected promise to be treated as an exception, you must handle the rejection with a .catch.

In angular-cache there is a getHandler function that contains the following line "return utils.Promise.reject(v);" This creates a promise and rejects it. However, this promise is not exposed, in any way, outside of the library and so you cannot handle it with a .catch.

As a consequence, if you are are using angular-cache to cache $http requests, even if you handle the rejection of the $http promise itself, you will still get a "Possibly Unhandled Rejection" error sent to the exceptionHandler because of this internal, rejected promise.

striche2 avatar Mar 16 '17 14:03 striche2

+1 This has been for a while now (at least since January).

For anyone getting here for a workaround: https://docs.angularjs.org/api/ng/provider/$qProvider

odedniv avatar Apr 09 '17 07:04 odedniv

Hey, any solution for this yet?

odedniv avatar Nov 08 '17 07:11 odedniv