Home > Software engineering >  Handle SQL exceptions in Entity Framework if a stored procedure in SQL Server already handles them?
Handle SQL exceptions in Entity Framework if a stored procedure in SQL Server already handles them?

Time:09-16

I am using an ASP.NET RESTful API with EF Core to communicate with a SQL Server database. I want to execute some stored procedures that handle exceptions. Do I also need to wrap my C# code to call the stored procedures in a try catch block?

In case I do not wrap the code in a try catch block, will C# throw an exception even if my stored procedure handled the exception?

CodePudding user response:

When your stored proc handle try catch block, then your stored proc will never throw an error because it will trap within proc. So there is no need to wrap try catch block from c#

  • Related