3 ms·
Yes, but if the success handler throws you won't catch it. For example: promise.then(function(){ throw new Error('Oh no, not caught'); }, function(err)
by Touche 10y ago
Yes, but if the success handler throws you won't catch it. For example:
promise.then(function(){
throw new Error('Oh no, not caught');
}, function(err){
});
But this will catch it:
promise.then(function(){
throw new Error('Oh no!');
}).catch(function(err){
// Caught it ;)
});
As will this:
promise.then(function(){
throw new Error('Oh no!');
}).then(null, function(err){
// Caught it ;)
});
Point being that your error handling need to be absolute last, and not paired with a success handler.