I've been searching for a while to find a way to trigger an error / catch from within a promise 'then' method.
Consider the following:
myPromiseToFetchAColor().then( (color) => {
if(color == "red"){
//THROW THE CATCH....with an error message
} else {
return aNewPromise();
}
}).catch( (error => {
console.log(error)
})
I know I can use another promise (a custom promise to do the validation on the color and then return the promise etc... but this seems over-kill. I'd love to just do my validation and then decide to continue, or through and error and trigger the catch.