I have a stored procedure in SQL Server that throws an error whenever a condition is hit. In order to catch this error and display it to the user, I use
try
{
//code
}
catch (Exception e)
{
return BadRequest(e.Message);
}
This catches most of the cases but on the other hand, this procedure has some print
messages that also get caught by this Exception
. Is there a way to catch the exception thrown only from RAISERROR
and ignore this print
message from SQL Server?