3 ms·
Actually, you can throw exceptions from within .then just fine and they will be always bubbled. You just cant go function g() { return somePromise.then(f
by spion 13y ago
Actually, you can throw exceptions from within .then just fine and they will be always bubbled. You just cant go
function g() {
return somePromise.then(function() {
setTimeout(function() {
throw new Error();
}, 500);
});
}
g(); // crash
But at that point, you're not using promises anymore so all bets are off.
However if you use a promise-based timeout too:
function f() {
return somePromise.then(function() {
return Q.delay(1000).then(function() {
throw new Error("Oops");
});
});
}
f().catch(function(e) {
console.log(e.message); // logs Ooops.
});
No problem bubbling that.