Most of the discussions online regarding SQL Server's error handling seem to be focus on how to gracefully handle errors thrown by the processing of T-SQL, using THROW, or TRY...CATCH, and so on.
What I have is a Stored Procedure which accepts several parameters. A couple of those parameters must only have values within a certain range, so at the start of my procedure I want to check the values that have been passed from the application (ASP.NET) and return an error if they aren't within the acceptable boundaries.
At the moment I've got:
IF @RequesterType <> 2 AND @RequesterType <> 3
BEGIN
RAISERROR('The value for RequesterType must be either 2 (Client) or 3 (Representative)', 10, 1)
RETURN;
END
When I execute the procedure that contains this code from within SSMS and pass a value other than 2 or 3, sure enough the message I've specified gets displayed. But it doesn't seem... severe enough. It doesn't seem apparent that an actual error has occurred.
I know it's possible to specify the severity parameter of the RAISERROR statement, but unless I'm going to make it very high (>19, I believe), indicating a fatal system error, I don't think that's going to make much difference.
I'm just wondering whether, with the code I've got, when the web application calls this procedure, it'll actually know that there's been a error. Would the VB.NET code calling the procedure know that an error has been thrown? If not, how could I re-write my procedure so that it would? I'm sure there's a best-practice way of doing this, but at the moment I feel like I'm trying to hack it.
I'm using SQL Server 2012.