On 5/24/05, Steve Bryant <[EMAIL PROTECTED]> wrote:
> I was thinking of using a type equal to the name of my component for any
> error thrown by my component.
> 
> For example, any error thrown by my DataMgr component would have <cfthrow
> type="DataMgr"...>

Bear in mind that the 'type' of an exception in CF is just a string so
the type="DataMgr" in your <cfthrow> has no connection to any
DataMgr.cfc except through the convention you are establishing.

Here's what the Macromedia Web Team CFMX Coding Guidelines say about
exceptions (we use the component name in the message but a feature
name in the type):

Exception Strategy

ColdFusion MX allows exceptions to have a pseudo-hierarchy by allowing
cfcatch to specify a type= attribute that has a compound dot-separated
name, like a component name, that will catch exceptions that have that
type or a more specific type, e.g.,

<!--- catches feature.subfeature.item: --->
<cfcatch type="feature.subfeature.item"> .. </cfcatch>
<!--- catches feature.subfeature.{anything}: --->
<cfcatch type="feature.subfeature"> .. </cfcatch>
<!--- catches feature.{anything}: --->
<cfcatch type="feature"> .. </cfcatch>

Each 'application' (or feature) should define and publish its
exception hierarchy. Most hierarchies will probably only have feature
and item, e.g., Membership.NO_SUCH_ATTRIBUTE. The intent is that the
feature.item (or feature.subfeature.item) type should entirely specify
what exception has occurred.

Each application should throw fully-qualified exception types
(feature.item or feature.subfeature.item) and a descriptive message
that says - in English - which component / method threw the exception
and a description of the problem, e.g.,

<cfset var msg = "MembershipAdminMgr.setAttributeName() :: " &
        "no attribute could be found with the given attribute name">
<cfthrow type="Membership.NO_SUCH_ATTRIBUTE" message="#msg#">

The code that invokes that application should catch the exceptions
using fully-qualified types that it can handle, followed by
feature.subfeature or feature for reporting more generic exceptions,
e.g.,

<cfcatch type="Membership.NO_SUCH_ATTRIBUTE">
    <!--- handle missing attribute error --->
</cfcatch>
<cfcatch type="Membership">
    <!--- handle general membership failure --->
</cfcatch>
<cfcatch type="application">
    <!--- handle general application failure --->
</cfcatch>
...
-- 
Sean A Corfield -- http://corfield.org/
Team Fusebox -- http://fusebox.org/
Got Gmail? -- I have 50, yes 50, invites to give away!

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood


----------------------------------------------------------
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).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to