I have a stored procedure, PROC
, which receives some parameters. If one of them, @ID
, is not null, a given stored procedure, PROC_A
, must be executed. Otherwise, PROC_B
must be executed. The problem is that both of them may issue a RAISERROR
, which I want to propagate through the call stack to be displayed at the client application. However, that RAISERROR
won't stop the rest of the PROC
stored procedure as it should, and, since I am using an IF
clause, checking IF ( @@ERROR <> 0 ) RETURN
isn't an option either. My only choice seems to be using a TRY...CATCH
block to wrap the IF
clause and rethrow the RAISERROR
from within the CATCH
block, which is awkwards because then I will have to cache ERROR_MESSAGE()
, ERROR_SEVERITY()
and ERROR_STATE()
and use RAISERROR
once again.
Isn't there really any more elegant way?