User Guide

Handling Exceptions in ColdFusion 211
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="Invalid_field.codeValue"
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 use this syntax:
<cfcatch type="Invalid_field.codeValue">
ColdFusion uses the catch type as a pattern to find a catch handler. For example,
<cfthrow type="MyApp.BusinessRuleException.InvalidAccount">
would be handled by any of the following cfcatch error handlers.
<cfcatch type="MyApp.BusinessRuleException.InvalidAccount">
<cfcatch type="MyApp.BusinessRuleException">
<cfcatch type="MyApp">
The handler that matches most exactly handles the error. Therefore, in this case, the
MyApp.BusinessRuleException.InvalidAccount handler gets invoked. However, if
you used the following
cfthrow tag:
<cfthrow type="MyApp.BusinessRuleException.InvalidVendorCode
the MyApp.BusinessRuleException handler receives the error.
The type comparison is case-insensitive. To match types exactly, rather than
performing pattern matching, use the cfsetting attribute
catchExceptionsByPattern="No".