You are here: Raising errors in a catch block in SQL2005 « MsSQL Server « IT news, forums, messages
Raising errors in a catch block in SQL2005

Posted by davidz on 05/03/06 02:13

When a catchable error occurs in a try block, control is passed to the
associated catch block. While I am then able to examine properties of
the error using such functions as ERROR_NUMBER() in the catch block,
the error-logging scheme used in my company requires that the actual
error be raised so that it can be picked up by components in the next
tier. I appear to be unable to do that -- I can raise some other error
that has all of the properties of the original except the error number.
For example, division by zero raises error 8134. If the code that
produces that error is enclosed in a try block, I seem to be unable to
raise that error from the catch block. Of course, if I never used the
try block to begin with this wouldn't be a problem, but then we
wouldn't have the advantages of this structure as it applies to other
errors, some of which we may wish to handle differently. While
Try-Catch looks great as a way of allowing us to handle errors in a
customized way and to avoid having all errors be passed up to our
middle tier, it seems that we are unable to pass ANY such errors
forward, and that is a problem for us, too. Is my understanding of
this situation correct, or is there some way around this problem, e.g.,
is there any way I could have raised error 8134, in the above example?
Thanks.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация