I know how to chain promises so that multiple success functions are executed. That is esplained in many examples. How do I chain promises so that multiple error functions are executed?
When an error is handled (and, either a value is returned or no value at all), the promise returned from then is considered resolved. You have to return a rejected promise from each error handler in order to propagate and chain error handlers.
For example:
promseA.then(
function success() {
},
function error() {
return $q.reject();
})
.promiseB.then(
function success() {
},
function error() {
return $q.reject();
})
.promiseC.then(
function success() {
},
function error() {
return $q.reject();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With