!3 Use ''Execute Procedure With Exception'' to check if a stored proc will throw an exception

Procedure was created with

{{{
CREATE PROCEDURE [dbo].[TestProc2]
	@iddocument int,
	@iddestination_user int
as
declare @errorsave int

set @errorsave = 0

if (@iddocument < 100)
begin
	set @errorsave = 53120
	raiserror(@errorsave, 15, 1, 'Custom error message')
	return @errorsave
end
}}}

Error must be registered in order for detailed error code checking to work!

!3 Just use "Expect exception" to expect any error

!|Execute Procedure Expect Exception|TestProc2|
|iddocument |iddestination_user|
|99|8|


!3 Use an explicit error code with ''Execute Procedure With Exception'' to for an explicit error code

note that, if user-defined error code is expected, this only works if error message is set using sp_addmessage 

!|Execute Procedure Expect Exception|TestProc2|53120|
|iddocument |iddestination_user|
|99|8|

!3 Execute procedure will still work ok if it does not throw an error

!|Execute Procedure|TestProc2|
|iddocument |iddestination_user|
|101|8|
