I've found having an error handler that can be 'nested' for composite objects works quite well. Maybe this is just common sense but I thought it was worth a mention.
Peter -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Dawson, Michael Sent: 14 March 2005 18:30 To: [email protected] Subject: RE: [CFCDev] Using Error Handling Objects 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. M!ke -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daniel Short Sent: Sunday, March 13, 2005 11:48 PM To: [email protected] Subject: [CFCDev] Using Error Handling Objects 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] ---------------------------------------------------------- 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] ---------------------------------------------------------- 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]
