> I create an instance of the error handler "within" my components. My
> error handler keeps an array of structures; one array element for each
> error.
>
> Then, my component returns the error handler object when the component
> has been validated. At that time, the error handler will contain all
> errors found in the validation.
>
> I originally thought about passing in a reference to the
> error object on
> each init, but that is extra busy-work that I won't want to mess with.
> I know that creating an instance within another component
> puts a bit of
> coupling in there. However, if I need to change something in
> the error
> handler that relates to client usage, more than likely it will also
> affect the internal workings of the client components as well.
This sounds like the way I may end up going. Just return either a struct, or
an error object back out of the cfc. I'm thinking that I can use <cfthrow>
and toss the cfcatch. data to the error object to help cut down on the need
for built in public methods such as "setFieldname" or "setErrorText".
Instead, I can just use the cfcatch.detail, cfcatch.errorCode, etc.
<cftry>
<!--- check for duplicate email address --->
<cfif DupEmail()>
<cfthrow type="validation" message="Dup Email" detail="Duh
man..." errorCode="emailAddress">
</cfif>
<cfcatch type="validation">
<cfset errObj.setError(cfcatch)>
</cfcatch>
</cftry>
Does that sound like a valid solution? Then my errObj gets to decide how to
deal with the cfcatch structure.
Dan
----------------------------------------------------------
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).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]