I don't agree that ColdFusion throws strings, Nat. ColdFusion
really does throw errors. Now, they're not subclassable like Java errors, but
you can put structured info into them. Here's some (gasp!) "actual code" showing
placed structured info into an error and throwing/catching
it:
<cftry>
<cftry>
<cfquery datasource="missing_datasource">
SELECT * FROM Authors
</cfquery>
<cfcatch type="Database">
<cfset error = StructNew() />
<cfset error.template = cgi.script_name />
<cfset error.serverSoftware = cgi.server_software />
<cfset error.requestMethod = cgi.request_method />
<cfwddx action="" input="#error#" output="error" />
<cfthrow type="CustomError" extendedinfo="#error#" detail="#cfcatch.detail#" errorcode="#cfcatch.errorCode#" message="The error message I received was: #cfcatch.message#" />
</cfcatch>
</cftry>
<cfcatch type="CustomError">
<cfwddx action="" input="#cfcatch.extendedinfo#" output="error" />
<cfdump var="#error#" label="Error" />
</cfcatch>
</cftry>
<cftry>
<cfquery datasource="missing_datasource">
SELECT * FROM Authors
</cfquery>
<cfcatch type="Database">
<cfset error = StructNew() />
<cfset error.template = cgi.script_name />
<cfset error.serverSoftware = cgi.server_software />
<cfset error.requestMethod = cgi.request_method />
<cfwddx action="" input="#error#" output="error" />
<cfthrow type="CustomError" extendedinfo="#error#" detail="#cfcatch.detail#" errorcode="#cfcatch.errorCode#" message="The error message I received was: #cfcatch.message#" />
</cfcatch>
</cftry>
<cfcatch type="CustomError">
<cfwddx action="" input="#cfcatch.extendedinfo#" output="error" />
<cfdump var="#error#" label="Error" />
</cfcatch>
</cftry>
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nat Papovich
Sent: Tuesday, November 22, 2005 2:05 PM
To: [email protected]
Subject: RE: [CFCDev] Error Handling Techniques...
Maybe Doug is looking for implementation details. Most of
us actually write code, and overviews are only occasionally
helpful.
Doug, one thing you may find is that you cannot throw
objects. Unlike other languages, ColdFusion only throws strings. I have not been
able to come up with a good way to throw structured information (or an object)
without resorting to storing an error object in the request scope and looking
for it when custom errors are thrown. That may be an option for you,
implementation-wise.
NAT
----------------------------------------------------------
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nando
Sent: Monday, November 21, 2005 1:56 PM
To: [email protected]
Subject: RE: [CFCDev] Error Handling Techniques...Have you listened to the latest "out loud" podcast?Not about specific implementation details, but a very good overview of the landscape, IMVHO.---------------------------------------------------------------Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Doug Arthur
Sent: Monday, November 21, 2005 10:23 PM
To: [email protected]
Subject: [CFCDev] Error Handling Techniques...I'm trying to come up with a best practice for error handling cfc's. Really, in my case, I should say error handle the actions within the cfc rather than error handling the cfc itself. I'm trying to error handle the actions that perform within the cfc and how to interpret those errors out to the user. Unfortanetly, the app I work on is out of my control and cannot conform to OO practices, or any practice at all for that matter. Although, I'd still like to know best practice in OO for myself.We execute stored proc's within an object's method. The stored proc's have a return code. If the return code is not 0, error handling needs to take place to display a customized message to the user and/or perform some type of action. Typically outside of a cfc, after a stored proc is executed, a request variables is set and an include file is added which handles the error handling process. I don't want to include html output or include any file that does this. I'd like to gear this process more towards an OO approach using another object or something that will be better.Some thoughts on the side I had --- Unfortanetly I can't use at work, but I am more interested in personally. :)What does anyone think about a resultsHandler object that is configurable to handle results from any cfc? Please forgive me if my thoughts or concepts are not on target with a true OO approach, as I'm learning a lot from this list still.Here are my thoughts:Having a resultsHandler object that can be passed the error handling object to perform error handling on the data. Then the resultsHandler object would be returned from the calling method. The resultsHandler would contain the return data set by the calling method and the resultsHandler would be the one to provide the results back to the user whether it's an error, or complete data.Here's a example off the top of my head how I can see this working:Calling Page:Variables.user = createObject("component", "user").init();Variables.user.getUserConfig(userId);User Object:- getUserConfig method:1. calls stored procedure, stored procedure's return code returns 501 (custom error code)2. Invokes errorHandler object, and passes object to resultsHanlder object.3. invokes setReturnValue() on resultsHandler object.4. returns resultsHandler object.resultsHanlder Object:- setReturnValue method:1. sets Variables.returnVal = argument- getReturnValue method (returntype any):1. checks if errorHandler.hasErrors()a. if so, set Variables.returnVal null or empty based on data type of the return type from the higher getUserConfig method.b. if not, returns Variables.returnVal(some other methods based on need for processing the error handling object, etc...)Any thoughts here would be greatly appreciated. Thanks in advanced!----------------------------------------------------------
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]
--
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.4/176 - Release Date: 11/20/2005
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]
