Are ES6 Promises swallowing your errors?

added by bpwndaddy
5/29/2015 2:50:40 PM

2 Kicks, 206 Views

When dealing with asynchronous code, JavaScript’s ES6 promises can make your life a lot easier. No more callback pyramids, no more error handling on every second line, and no more reliance on external libraries to do things as simple as getting the result of a for loop. But ES6 Promises can have their own pitfalls, the biggest by far being disappearing error messages. Reddit’s /u/ledp put it better than I ever could: "What the actual flying fuck? Promises swallows errors by default! Who’s idea was that?" More specifically, any exception which is thrown within a then handler, a catch handler, or within the function passed to new Promise, will be silently disposed of unless manually handled.


0 comments