Here's the skeleton of the function:

<cffunction name="getUser" returntype="userCFC">
  ...
  <cfif doesUserExist>
    <cfreturn theUser />
  <cfelse>
    <cfthrow type="UserNotFoundException" />
  </cfif>
</cffunction>

And then calling it:

<cftry>
  <cfset user = getUser() />
  .. do stuff ..
  <cfcatch type="UserNotFoundException">
    .. deal with the invalid user ..
  </cfcatch>
</cftry>

Just for references, with a "null" return value the function would
return some kind of null instead of throwing the exception, and the
calling code would look like this:

<cfset user = getUser() />
<cfif user is null>
  .. deal with invalid user ..
<cfelse>
  .. do stuff ..
</cfif>

cheers,
barneyb

On 10/22/05, Andrew Scott <[EMAIL PROTECTED]> wrote:
> Barney,
>
> If you don't mind I would like an example to clarify, in this example I am
> checking to see if a user exists, it returns the user object if it does. So
> when it returns back to the caller how do I handle it, if you can give me an
> example to help clarify what your saying that would be much appreciated.
>
>
> Regards,
> Andrew Scott


--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 100 invites.


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to