Errors threwn from server are not showing in sweet alert in Angular 11

166 Views Asked by At

I recently updated my app from Angular 2 to Angular 11. Before update whenever an error is thrown from server, it was shown in Sweet Alert modal. But after update errors from server are not showing in sweet alert error modal. Rather, in browser console an error is shown, saying server error. I think error is not handled properly. But don't know how to fix it.

Front End

`

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);
        }
    )
}

`

Back End(Error throwing)

`

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);
}

`

0

There are 0 best solutions below