As a general rule, it is better form to explicitly pass the error value your wish to report. The reason is that if you include a "KiXtart command" your UDF, it may be the case that it will reset the value of @error which could cause your function to log an incorrect error.

The best programming methodology would be to store the value of @error & @serror in variables immediately after the the command you want to check. Then use the variable for further processing to avoid any chance of @error changing values unexpectedly.
_________________________
Home page: http://www.kixhelp.com/hb/