Before creating or updating an entry, I am performing validations using the code snippet below:
async save(){
return new Promise((resolve, reject)=>{
if(!this.isCampaignValid){
this.handleError()
reject()
}
else{
this.$store
.dispatch('updateCampaign')
.then((res)=>{
resolve()
this.showNotification(res.message, 'success')
})
.catch(error=>{
this.showNotification(error.message, 'error')
reject()
})
}
})
},
The validity of the campaign is determined by the computed value isCampaignValid
.
If the campaign is not valid, an error message appears in the console:
Uncaught (in promise) undefined
The function this.handleError()
is also executed. How can I handle this promise error situation effectively?