Base solution for your next web application
Open Closed

How to catch specific database exceptions during DB DML statements? #12298


User avatar
0
MainTechAS created

In the APB framework, what possibilities are there to catch specific database exceptions during DB DML statements? e.g. when using ReferentialAction.Restrict in EF Core, one might catch the foreign key constraint violation exception and display a more intuitive message than "An internal error occurred during your request!"


1 Answer(s)
  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @MainTechAS,

    We prefer not to share the errors in detail with users. You can see the error in the logs. If you want to show an error please catch the error and use like the following code

    throw new UserFriendlyException("Ooppps! There is a problem!", "You are trying to see a product that is deleted...");