Hi everyone,
I'm trying to figure out the "best" way to handle user validation errors
inside my CFCs. I've written CFCs previously that used a returned struct
directly from the CFC with the errors for the current method. But I'm
thinking it might be a good idea to create a global "Error Handler" cfc that
would have just a few methods, like:
setError("fieldname", "ErrorTitle", "ErrorString")
getError("fieldname")
getErrors() - Returns full struct of errors
Then errors inside the object would be managed by a structure. My problem
with this is how do I reference this global error object? Do I pass it in
for each DAO method I use? So for example, would I do something like this?:
<cfset ErrObject = CreateObject("component", "cfc.ErrorHanderl").init()>
<cfset User = CreateObject("component", "cfc.User").init()>
<!---
Do some sets on the user
--->
<cfset User.Update(ErrorObject)>
I'm not quite sure if I'm taking the right approach here and just asking for
trouble, since all of my objects will have to know about the error handlers
methods. I think this is valid composition but would somewhat break the
encapsulation of my objects.
Thanks in advance,
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]