当尝试失败时,我正在尝试中断Promise链的执行,但是它仍然可以编译该链,但是,在特定方法中发生了错误。
this.addParticipantByEmail(email, type)
.then(() => this.issueIdentity(email, type))
.then(cardData => this.dataService.importWallet(cardData))
.then(() => this.authService.signupUser(email, password, type))
.then( () => {
this.spinner.hide();
})
.catch(error => {
if (error === "Server error") {
return (this.errorMessage =
"Could not connect to REST server. Please check your configuration details");
} else {
return (this.errorMessage = error);
}
});
addParticipantByEmail(email: string, type: string): Promise<any> {
this.initiateParticipant(email, type);
// Add the participant using the admin account to the Blockchain through COMPOSER-REST-API
return this.service
.addParticipantAsAdmin(this.participant)
.toPromise()
.catch(error => {
if (error === "Server error") {
this.errorMessage =
"Could not connect to REST server. Please check your configuration details";
} else {
this.errorMessage = error;
}
});
}
当其中一个promise中发生错误时,我想停止promise链。