Error handling in UDFs can be accomplished many ways.
1) Let the server handle it. Imagine a UDF that returns the length of an
array. (Yes, we have a built in function for that...) It could look like
so:
function myArrayLen(a) {
return arrayLen(a);
}
If you pass a structure instead of an array to myArrayLen, the server
will automatically throw an error. This may be what you want.
2) Return a particular value. Taking the same example, you could make it
return -1 for non array values:
function myArrayLen(a) {
if(not isArray(a)) return -1;
return arrayLen(a);
}
Then, check the result.
Make sense?
=======================================================================
Raymond Camden, ColdFusion Jedi Master for Macromedia
Email : [EMAIL PROTECTED]
Yahoo IM : morpheus
"My ally is the Force, and a powerful ally it is." - Yoda
> -----Original Message-----
> From: Thane Sherrington [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 03, 2002 11:12 AM
> To: CF-Talk
> Subject: Returning Error codes with a UDF.
>
>
> I want my UDF to return an error code if there is a problem,
> otherwise
> return a value. Would it look something like this?
>
> If IsDefined("ErrorCode")
> {
> Return ErrorCode;
> Else
> Return VariableName;
> }
>
> So then I should be able to do something like:
>
> <CFIF val(MyUdf(VariablePassed)) EQ 0>
> <CFSET Variable=MyUDF(VariablePassed)>
> </CFIF>
>
> Or am I off base?
>
> T
>
>
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists