4 ms·
FWIW, I think JS swallows all async errors regardless of whether you use .catch(). If the error is thrown async, you can't catch it. Right?
by linkmotif 11y ago
FWIW, I think JS swallows all async errors regardless of whether you use .catch(). If the error is thrown async, you can't catch it. Right?
- cwp 11y agoNo. This is the whole point of promises.
- dmethvin 11y agoPerhaps the gp meant this case? something().then(function(){ setTimeout(function(){ whoops_not_a_function(); }, 1000); }).catch(function(){ // nope, nothing to catch });
- phs2501 11y agoNo built-in help with native promises, but with something like Bluebird you'd prefer: something().then(() => { return Promise.delay(1000).then(() => { whoops_not_a_function(); }); }).catch(() => { // whoops_not_a_function is not defined }); ...or write Promise_delay yourself on top of native promises (but really just use Bluebird).
- linkmotif 11y agoYup this is what I meant. Thanks. Yeah arrow functions help.