javascript - 错误时打破承诺链执行[重复]
问题描述
当它失败时,我试图打破承诺链执行,但它仍然编译链,但是,在特定方法中发生了错误。
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;
}
});
}
当其中一个承诺发生错误时,我想停止承诺链。
解决方案
推荐阅读
- python - 使用正则表达式删除 html 标签
- c# - Kinect V2 - 如何将 kinect v2 坐标转换为现实生活中的测量值?
- reactjs - 如何将类添加到地图语句中的当前元素
- automation - 选择器提取不同类型的元素值 tagName
- css - 编辑编译的css文件
- azure - Jenkins 管道未部署到 azure
- xcode - 如何在 Xcode 中临时禁用通过 POD 文件添加的框架
- typescript - 如何在打字稿中声明递归类型以进行方法链接?
- python - 我如何使用 python 和 selenium 自动登录网站
- c# - 覆盖 DataColumn 的 clone()