MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 308

Developing coldfusion mx applications
Table of Contents

Advertisement

Catching and displaying thrown errors
The
tag catches a custom exception when you use any of the following values for the
cfcatch
attribute:
cfcatch type
The custom exception type specified in the
A custom exception type that hierarchically matches the initial portion of the type specified in
the
tag. For more information, see the next section,
cfthrow
hierarchy".
Application
attribute or with no
, which matches any exception that is not caught by a more specific
Any
Similarly, if you specify any of these types in a
information about the thrown error.
Because the
cfthrow
handler can also display these errors.
Custom error type name hierarchy
You can name custom exception types using a method that is similar to Java class naming
conventions: domain name in reverse order, followed by project identifiers, as in the following
example:
<cfthrow
type="com.myCompany.myApp.Invalid_field.codeValue"
errorcode="Dodge14B">
This fully qualified naming method is not required; you can use shorter naming rules, for
example, just myApp.Invalid_field.codeValue, or even codeValue.
This naming method is not just a convention, however; ColdFusion MX uses the naming
hierarchy to select from a possible hierarchy of error handlers. For example, assume you use the
following
cfthrow
<cfthrow type="MyApp.BusinessRuleException.InvalidAccount">
Any of the following
<cfcatch type="MyApp.BusinessRuleException.InvalidAccount">
<cfcatch type="MyApp.BusinessRuleException">
<cfcatch type="MyApp">
The handler that most exactly matches handles the error. Therefore, in this case, the
MyApp.BusinessRuleException.InvalidAccount
the following
cfthrow
<cfthrow type="MyApp.BusinessRuleException.InvalidVendorCode
the
MyApp.BusinessRuleException
The type comparison is no case-sensitive.
When to use cfthrow
Use the
cfthrow
One typical use for the
is also useful for throwing errors from a custom tag page to the calling page.
308
Chapter 14: Handling Errors
, which matches an exception that is thrown with the
attribute.
type
tag generates an exception, a Request error handler or the Site-wide error
statement:
error handlers would handle this error:
cfcatch
tag:
handler receives the error.
tag when your application can identify and handle application-specific errors.
tag is in implementing custom data validation. The
cfthrow
tag.
cfthrow
"Custom error type name
tag, the specified error page will display
cferror
handler gets invoked. However, if you used
Application type
tag.
cfcatch
cfthrow
tag

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion mx

Table of Contents