User Guide

Table Of Contents
Handling runtime exceptions with ColdFusion tags 325
For cases when a cfcatch block is not able to successfully handle an error, consider using the
cfrethrow tag, as described in “Using the cfrethrow tag” on page 333.
If an exception can be safely ignored, use a cfcatch tag with no body; for example:
<cfcatch Type = Database />
In particularly problematic cases, you might enclose an exception-prone tag in a specialized
combination of
cftry and cfcatch tags to immediately isolate the tag's exceptions.
Exception information in cfcatch blocks
Within the body of a
cfcatch tag, the active exceptions properties are available in a cfcatch
object. The following sections describe the object contents.
Standard cfcatch variables
The following table describes the variables that are available in most cfcatch blocks:
Note: If you use cfdump to display the cfcatch variable, the display does not include variables that do
not have values.
The cfcatch.TagContext variable contains an array of tag information structures. Each
structure represents one level of the active tag context at the time when ColdFusion detected the
exception. That is, there is one structure for each tag that is open at the time of the exception. For
example, if the exception occurs in a tag on a custom tag page, the tag context displays
information about the called custom tag and the tag in which the error occurs.
Property variable Description
cfcatch.Detail
A detailed message from the CFML compiler. This message, which can
contain HTML formatting, can help to determine which tag threw the
exception.
The
cfcatch.Detail value is available in the CFScript cfcatch statement as
the
exceptionVariable parameter.
cfcatch.ErrorCode
The cfthrow tag can supply a value for this code through the errorCode
attribute. For
Type="Database", cfcatch.ErrorCode has the same value as
cfcatch.SQLState.
Otherwise, the value of
cfcatch.ErrorCode is the empty string.
cfcatch.ExtendedInfo
Custom error message information. This is returned only to cfcatch tags for
which the
type attribute is Application or a custom type.
Otherwise, the value of
cfcatch.ExtendedInfo is the empty string.
cfcatch.Message
The exception’s default diagnostic message, if one was provided. If no
diagnostic message is available, this is an empty string.
The
cfcatch.Message value is included in the value of the CFScript catch
statement
exceptionVariable parameter.
cfcatch.RootCause
The Java servlet exception reported by the JVM as the cause of the “root
cause” of the exception.
cfcatch.TagContext
An array of structures structure containing information for each tag in the
tag stack The tag stack consists of each tag that is currently open.
cfcatch.Type
The exception’s type, returned as a string.