User Guide

206 Chapter 11 Preventing and Handling Errors
Applications can optionally use the cfthrow tag to raise custom exceptions. Such
exceptions are caught with any of the following type specifications:
type="custom_exception_type"
type="application"
type="any"
The custom_exception_type type designates the name of a user-defined type
specified in the
cfthrow tag.
An exception raised within a
cfcatch block cannot be handled by the cftry block
that immediately encloses the
cfcatch tag.
Exception information in cfcatch
Within a cfcatch block, the active exceptions properties can be accessed as
variables. The following variables are available in most cfcatch blocks:
Tag context information
On the Debugging Settings page in the ColdFusion Administrator you can select the
Enable CFML stack trace option. When you enable this option,
cfcatch blocks make
available an array of structures called
cfcatch.tagContext. Each structure represents
one level of the ColdFusion runtimes active tag context at the time when the
ColdFusion interpreter detected the exception.
Property variable Description
cfcatch.type
The exceptions type, returned as a string.
cfcatch.message
The exceptions diagnostic message, if one was provided.
If no diagnostic message is available, this is an empty
string.
cfcatch.detail
A detailed message from the CFML interpreter. This
message, which contains HTML formatting, can help to
determine which tag threw the exception.
cfcatch.extendedInfo
A custom error message. This is returned only for cfcatch
tags where
type="Application" or a custom type.
cfcatch.errorCode
Any exception that is a part of the CFML exception
hierarchy supplies a value for this variable.
For
type="Application", cfthrow tags can supply a
value for this code via 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.tagContext
Provides the name and position of each tag in the tag
stack and the full pathnames of the files that contain the
tags in the tag stack.