Here's the synchronous analogy:
try {
actionA(); // throws
actionB(); // skipped
actionC(); // skipped
} catch (e) {
// can't resume
}
but you want:
try{
try {
actionA(); // throws
} catch (e) {
if(error.type !== 'missing'){
throw error; // abort chain
}
// keep going
}
actionB(); // executes normally if error type was 'missing'
actionC();
} catch (e) {
// handle errors which are not of type 'missing'.
}
Here's the promise version:
asyncActionA() // <-- fails with 'missing' reason
.catch(error => {
if(error.type !== 'missing'){
throw error; // abort chain. throw is implicit Promise.reject(error);
}
// keep going, implicit: return Promise.resolve();
})
.asyncActionB(promiseB) // <-- runs
.asyncActionC(promiseC)
.catch(err => {
// handle errors which are not of type 'missing'.
});
.then
has 2 arguments..fulfill
andreject
.. You can deal withreject
– Tenuous