Created
August 13, 2014 13:37
-
-
Save SeriousM/027bff66984d1c53cd2f to your computer and use it in GitHub Desktop.
TSQL Rethrow Exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN TRY | |
... | |
END TRY | |
BEGIN CATCH | |
ROLLBACK TRANSACTION; | |
THROW; | |
END CATCH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN TRY | |
... | |
END TRY | |
BEGIN CATCH | |
ROLLBACK TRANSACTION; | |
DECLARE @ErrorMessage nvarchar(4000) = ERROR_MESSAGE(), | |
@ErrorNumber int = ERROR_NUMBER(), | |
@ErrorSeverity int = ERROR_SEVERITY(), | |
@ErrorState int = ERROR_STATE(), | |
@ErrorLine int = ERROR_LINE(), | |
@ErrorProcedure nvarchar(200) = ISNULL(ERROR_PROCEDURE(), '-'); | |
SELECT @ErrorMessage = N'Error %d, Level %d, State %d, Procedure %s, Line %d, ' + 'Message: ' + @ErrorMessage; | |
RAISERROR (@ErrorMessage, @ErrorSeverity, 1, @ErrorNumber, @ErrorSeverity, @ErrorState, @ErrorProcedure, @ErrorLine); | |
END CATCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment