Почему не отрабатывает catch у внутреннего промиса?
Подскажите пожалуйста, почему у внутреннего прописа не отрабатывает catch?
onFormSubmit = ({ email }: IFormValues) => {
return new Promise<void>((resolve, reject) => {
this.props
.setProfile({ email })
.then(() => {
this.isEmailError = false;
this.setProductSubscription(true)
.then(() => resolve())
.catch((errors: IError[]) => { // Вот этот catch
console.log('errors', errors)
});
})
.catch((errors: IError[]) => {
return handleValidationErrors(errors);
});
})
};
setProductSubscription = (isSubscribed: boolean) => {
return this.props
.setProductSubscription(this.props.productId, isSubscribed)
.then(() => {
if (isSubscribed && !this.state.isSidebarRendered) {
Notification.success(createTranslatable('productSubscriptionSubscribedSuccessfully'));
}
})
.catch((errors: IError[]) => {
this.isEmailError = getValidationErrorByCode(errors, ERROR_CODE_NO_EMAIL)?.code === ERROR_CODE_NO_EMAIL;
if (this.isEmailError) {
return this.renderSidebar();
}
showValidationErrors(errors);
});
};
Источник: Stack Overflow на русском