Base solution for your next web application
Open Closed

Cannot catch the exception #10175


User avatar
0
Simonlum created

Dear team, If there are some relationships under the master entity,when user delete the entity i want to pop friendly message instead of the 500. I used try catch in delete method, but the method cannot catch the exception i want to catch ,it still pop the 500. could you give me some advices thanks. my code as below; public async Task Delete(EntityDto<long> input) { try { await _companyRepository.DeleteAsync(input.Id); } catch(Exception ex) { throw new UserFriendlyException(L("CannotDeleteSupplier")); } }


1 Answer(s)
  • User Avatar
    0
    Romka created

    Hello,

    (I'm a customer as you are, but I already faced this kind of issue :)

    Are you 100% sure the code does enter your method ? The 500 error may be related to something else, like invalid EntityDto<> parameter. Can you post the error log (in the "App_Data\Logs\logs.txt" file) ?