User Guide

102 Developing Web Applications with ColdFusion
<UL>
<LI><B>Message:</B> #CFCATCH.message#
<LI><B>Detail:</B> #CFCATCH.Detail#
</UL>
</CFOUTPUT>
4 </CFCATCH>
4 </CFTRY>
</BODY>
</HTML>
Custom Exception Types
The TYPE attribute allows a CFTHROW tag to throw an exception of a specific type,
which can be caught by a CFCATCH tag that has a matching TYPE attribute.
A CFTHROW tag without a TYPE attribute will throw a TYPE="Application" exception.
Naming conventions
A naming convention for custom exception types follows a convention that is similar
to Java class naming conventions: domain name in reverse order, followed by project
identifiers, as in this example:
<CFTHROW
TYPE="COM.Allaire.ProjectName"
ERRORCODE="Dodge14B">
The predefined exception types, except for TYPE="APPLICATION" are reserved; for
example, <CFTHROW TYPE="Database"> will be rejected.
A CFCATCH tag can specify a custom type as well as one of the predefined types. For
example, to catch the exception thrown above, you would use this syntax:
<CFCATCH TYPE="COM.Allaire.ProjectName">
ColdFusion uses the catch type as a pattern to find a catch handler. For example,
<CFTHROW TYPE="MyApp.BusinessRuleException.InvalidAccount">
would try to find:
<CFCATCH TYPE="MyApp.BusinessRuleException.InvalidAccount">
<CFCATCH TYPE="MyApp.BusinessRuleException">
<CFCATCH TYPE="MyApp">
The type comparison is case-insensitive. To match types exactly, rather than
performing pattern matching, use the CFSETTING attribute
CATCHEXCEPTIONSBYPATTERN=No.