0

我最近将我的应用程序从Angular 2更新到Angular 11。每当从服务器抛出错误时,在更新之前,它都会以 Sweet Alert 模式显示。但是在服务器的更新错误没有显示在甜蜜警报错误模式中。相反,在浏览器控制台中会显示一个错误,即服务器错误。我认为错误处理不当。但不知道如何解决。

前端

`

deleteChequeInfo(chequeInfo): void {
    let input = new DeleteChequeInfoInput();
    input.id = chequeInfo.id;
    this._chequeInfoService.deleteChequeInfo(input)
    .pipe(finalize(() => this.primengDatatableHelper.hideLoadingIndicator()))
    .subscribe(
        (data) => {
            this.notify.success(this.l('DeletedSuccessfully'));
            this.diractiveBack.emit(null);
        }
    )
}

`

后端(错误抛出)

`

public async Task DeleteChequeInfo(EntityDto<long> input){

    var chequeInfo = _ChequeInfoRepository.FirstOrDefault(ci => ci.Id == input.Id);

    if (chequeInfo.PaidAmount > 0) {
        throw new UserFriendlyException("Invoice Is Created"); //this is the error throwing from server
    }

    await _ChequeInfoRepository.DeleteAsync(input.Id);
}

`

4

0 回答 0