If the calling component knows that the method is interacting with a database (i.e. the called component is a dedicated database interaction component), then throwing a database error isn't breaking encapsulation.
If that's not the case, I'm of a mixed opinion. In Java, you can throw an exception and specify the root cause, but in CF, you can't throw an exception object, you can only throw a generic exception with a specific name. in that case, i think it'd be better to let the database error propogate, but the calling component shouldn't be looking for a database exception, rather just any exception. I've been playing with a very simple framework (made up of a couple custom tags) that allows you to synthesize throwing exception objects, rather than just strings. Thus far it's worked pretty well, but I'm not sure it's quite right yet. However, it definitely makes exception handling much more useful. cheers, barneyb On Thu, 22 Jul 2004 10:12:55 -0700, Ben Curtis <[EMAIL PROTECTED]> wrote: > > Ok, so it took me two days to read through this thread. Sue me. ;) > > >> If your query fails, the component doing the query should > >> throw an exception, which is handled by the calling code. It > >> shouldn't pass back a valid value unless the operation was > >> successful (or at least successful enough). That's the point > >> of exceptions, after all. > >> > > > > Big plus one to this. I can't see why you would want to supress the > > error. > > This may be an excessively fine point, but I think suppressing the > error is exactly what he meant. > > I read Barney to mean that if the function fails, it should throw an > exception. The calling code shouldn't need to know that the function is > calling a database in order to examine the exception as a database > error. If the query fails, the function should catch it, understand it, > and if the failure causes the function to fail then the function should > throw an exception back to the calling code. But, IMO, to throw the raw > query failure back is breaking encapsulation, so you must suppress that > in the function and replace it with something function-specific > > That said, I hardly adhere to such a rigorous rule 100% of the time, > but since we're talking about ideals here I figured I'd chime in. > > -- > > Ben Curtis > WebSciences International > http://www.websciences.org/ > v: (310) 478-6648 > f: (310) 235-2067 > > > > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED] > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
