Exception Information in CFCATCH

Within a CFCATCH block, the active exception's properties can be accessed as variables:

Exception Property Variables 
Property variable Description
CFCATCH.TYPE 
The exception's type, returned as a string:
CFCATCH.MESSAGE
The exception's 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 may 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 path names of the files that contain the tags in the tag stack.

Tag context information

The ColdFusion Administrator's debugging settings page allows you to"Enable CFML stack trace." When this setting is enabled, CFCATCH blocks make available an array of structures called CFCATCH.TagContext. Each structure represents one level of the ColdFusion runtime's active tag context at the time when the ColdFusion interpreter detected the exception.

The structure at position 1 of the array represents the outermost tag in the stack of tags that were executing when the interpreter detected the exception. The structure at position ArrayLen(CFCATCH.TAGCONTEXT) represents the currently executing tag at the time the interpreter detected the exception.

The TagContext structures have the following attributes:

TEMPLATE -- The pathname of the application page that contains the tag.

LINE and COLUMN -- The tag's line number and column number within the application page.

Note Turn off "Enable CFML stack trace" to avoid having production servers expend resources creating a traceback stack by default. When this setting is disabled, CFCATCH.TAGCONTEXT is a zero-length array.

Database exceptions

For database exceptions, ColdFusion supplies some additional diagnostic information. The following variables are available whenever the exception type is database:

Property variable Description
CFCATCH.NATIVEERRORCODE
The native error code associated with this exception. Database drivers typically provide error codes to assist in the diagnosis of failing database operations. The values assumed by CFCATCH.NATIVEERRORCODE are driver-dependent. If no error code is provided, the value of NativeErrorCode is -1.
CFCATCH.SQLSTATE
The SQLSTATE code associated with this exception. Database drivers typically provide error codes to assist in the diagnosis of failing database operations. The values assumed by CFCATCH.SQLSTATE are driver-dependent. If no SQLSTATE value was provided, the value of SQLSTATE is -1.

Expression exceptions

Property variable Description
CFCATCH.ERRNUMBER
An internal expression error number, valid only when TYPE="Expression"

Locking exceptions

For exceptions related to CFLOCK sections, there is additional information available within the CFCATCH block:

Property variable Description
CFCATCH.LOCKNAME
The name of the affected lock. This is set to "anonymous" if the lock name is not known.
CFCATCH.LOCKOPERATION
The operation that failed. This is set to "unknown" if the failed operation is unknown.

MissingInclude exceptions

For exceptions related to missing files, where the type of exception is MissingInclude, the following variable is available:

Property variable Description
CFCATCH.MISSINGFILENAME
The name of the file missing in an exception of type MissingInclude.