Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 301

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Developing CFML Applications
, which matches any exception that is not caught by a more specific
Any
Similarly, if you specify any of these types in a
thrown error.
Because the
tag generates an exception, a Request error handler or the Site-wide error handler can also
cfthrow
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,
myApp.Invalid_field.codeValue, or even codeValue.
This naming method is not just a convention; ColdFusion uses the naming hierarchy to select from a possible
hierarchy of error handlers. For example, assume that you use the following
<cfthrow type="MyApp.BusinessRuleException.InvalidAccount">
Any of the following
cfcatch
<cfcatch type="MyApp.BusinessRuleException.InvalidAccount">
<cfcatch type="MyApp.BusinessRuleException">
<cfcatch type="MyApp">
The handler that most exactly matches handles the error. In this case, the
MyApp.BusinessRuleException.InvalidAccount
<cfthrow type="MyApp.BusinessRuleException.InvalidVendorCode
the
MyApp.BusinessRuleException
The type comparison is not case sensitive.
When to use the cfthrow tag
Use the
tag when your application can identify and handle application-specific errors. One typical use for the
cfthrow
tag is in implementing custom data validation. The
cfthrow
custom tag page to the calling page.
For example, on a form action page or custom tag used to set a password, the application can determine whether the
password entered is a minimum length, or contains both letters and number, and throw an error with a message that
indicates the password rule that was broken. The
problem.
Using the cfrethrow tag
The
tag lets you create a hierarchy of error handlers. It tells ColdFusion to exit the current
cfrethrow
and "rethrow" the exception to the next level of error handler. Thus, if an error handler designed for a specific type of
error cannot handle the error, it can rethrow the error to a more general-purpose error handler. The
can only be used in a
cfcatch
The cfrethrow tag syntax
The following pseudocode shows how you can use the
tag, the specified error page displays information about the
cferror
error handlers would handle this error:
handler runs. However, if you used the following
handler receives the error.
block handles the error and tells the user how to correct the
cfcatch
tag body.
cfrethrow
Last updated 1/20/2012
tag.
cfcatch
statement:
cfthrow
tag is also useful for throwing errors from a
cfthrow
tag to create an error-handling hierarchy:
296
tag:
cfthrow
block
cfcatch
tag
cfrethrow

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents