Macromedia coldfusion 4.5-cfml language reference User Manual
232
CFML Language Reference
CFTRY/CFCATCH
Used with one or more CFCATCH tags, the CFTRY tag allows developers to catch and
process exceptions in ColdFusion pages. Exceptions include any event that disrupts
the normal flow of instructions in a ColdFusion page such as failed database
operations, missing include files, and developer-specified events.
process exceptions in ColdFusion pages. Exceptions include any event that disrupts
the normal flow of instructions in a ColdFusion page such as failed database
operations, missing include files, and developer-specified events.
Syntax
<CFTRY>
... Add code here
<CFCATCH TYPE="exceptiontype">
... Add exception processing code here
</CFCATCH>
... Additional CFCATCH blocks go here
</CFTRY>
... Add code here
<CFCATCH TYPE="exceptiontype">
... Add exception processing code here
</CFCATCH>
... Additional CFCATCH blocks go here
</CFTRY>
TYPE
Optional. Specifies the type of exception to be handled by the CFCATCH block:
•
APPLICATION (default)
•
Database
•
Template
•
Security
•
Object
•
MissingInclude
•
Expression
•
Lock
•
Custom_type
•
Any (default)
Usage
You must code at least one CFCATCH tag within a CFTRY block. Code CFCATCH tags at
the end of the CFTRY block. ColdFusion tests CFCATCH tags in the order in which they
appear on the page.
the end of the CFTRY block. ColdFusion tests CFCATCH tags in the order in which they
appear on the page.
If you specify the type to be ANY, do so in the last CFCATCH tag in the block so that all
of the other tests are executed first.
of the other tests are executed first.
Note
Specifying the type as ANY causes the ColdFusion Application Server to
catch exceptions from any CFML tag, data source, or external object,
which your application may not be prepared to handle.
catch exceptions from any CFML tag, data source, or external object,
which your application may not be prepared to handle.
Applications can optionally use the
CFTHROW
tag to raise custom exceptions. Such
exceptions are caught with any of the following type specifications:
•
TYPE="custom_type"
•
TYPE="APPLICATION"