>
> var rejected = Promise.reject(new Error("bad news!"));
> var fulfilled = Promise.resolve(5);
>
> fulfilled.then(() => {
> rejected.catch(err => console.error(err));
> });
>
>
In my implementation, this works for two reasons. First, "root" promises
(i.e. not created via `then`) such as `rejected` above are not "throwable".
Second, errors are not thrown until after the callback queue has been
repeatedly flushed, until empty. Both arrow functions above would execute
before the next checkpoint.
This, however, would crash the program:
Promise.reject(new Error("bad news!")).then(x => x);
As would this:
var rejected = Promise.reject(new Error("bad news!")).then(x => x);
setTimeout($=> rejected.catch(err => console.log(err)), 0);
{ Kevin }
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss