To check for an error you use @@ERROR immediately after the given statement:
IF @@ERROR <> 0 <do something>
To raise a custom message, you can use the RAISERROR command:
RAISERROR( 'ERROR: bla-bla-bla', 16, -1 )
You could also create custom error messages in sysmessages and call those by number:
RAISERROR( 50001, 16, -1 )