Re:Error Handling in Nodejs
by qudat on Friday July 17, 2015 @10:11AM
(#9902774)
Agreed! I literally just dealt with this eariler in the work week, spent hours trying to figure out why an error wasn't properly being thrown in my unit tests ... forgot to catch the promise chain -.-
This applies to functions that are async as well in babel:
async function get(url) {
throw new Error('hi there');
}
// wont throw the error
get('http://google.com');
// catch the error
get('http://google.com').catch(function(err) {
throw err;
});
This applies to functions that are async as well in babel: