MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 231

Table of Contents

Advertisement

Handling Exceptions in ColdFusion
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
The predefined exception types, except for
example,
A
cfcatch
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 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
you used the following
<cfthrow type="MyApp.BusinessRuleException.InvalidVendorCode
the
The type comparison is case-insensitive. To match types exactly, rather than
performing pattern matching, use the
catchExceptionsByPattern="No"
type="Invalid_field.codeValue"
errorcode="Dodge14B">
<cfthrow type="Database">
tag can specify a custom type as well as one of the predefined types. For
MyApp.BusinessRuleException
type="Application",
will be rejected.
cfcatch
tag:
cfthrow
handler receives the error.
cfsetting
.
are reserved; for
error handlers.
handler gets invoked. However, if
attribute
211

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents