$q: Rejected Promises with non rejection callback should report the rejection reason in the console. #13653
Description
Eg: If I write the code below:
var promise2 = Promise.resolve(8).then(function(value){
alter(value)
})
Notice the alter
(should be alert
) function which is not exist and will cause an error which will be caught and adopted by the promise returned by the last then which is the promise2
.
If you run this code in console, you'll see something like Uncaught (in promise) ReferenceError: alter is not defined(…)
in console.
The primitive Promise in ES6 will report rejected reason in console when the promise has no rejection handler.
But if you change the Promise
to $q
in the above code snippet, you won't see the error reported in console. Which is bacsuse $q did not do this.
Sometimes if the promise returned by the last then
method in promise chain and something went wrong in the last then
method, the promise will got rejected, if the promise implementation do not report the error in the console, the developers would never know the error unless he/she dive deep in the code...
On the contrary, Q's done
method can report the error(but if you don't chain a done
method in the promise chain, it won't), and Bluebird will always report the error(and some useful warnings) in console if a rejected promise has no rejection handler.
$q(do not report error on rejected promise):
Eh...as I wrote this, I found that since angular 1.4.x, it starts to report the error or exception caught in the promise but even if the exception will be processed in the subsequent promise chain, it still report the error which is not a desired behavior:
What is thought to be the desired behavior is that it only report rejected promises' errors when there is no rejection handler registered on the promise(that is, never called then(*,handler)
on it), which is like Q or Bluebird or ES6 primitive Promise.