You can use @@Error within your T-SQL Code. It's been a while since I've coded with it, so I can't give you an exact suggestion, but check it out in Books Online.
Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"