CFERROR

Provides the ability to display customized HTML pages when errors occur. This allows you to maintain a consistent look and feel within your application even when errors occur.

CFERROR
Attribute

Description

TYPE

The type of error which this custom error page is designed to handle. Specify REQUEST to handle errors which occur during the processing of a template; specify VALIDATION to handle data input validation errors which occur when submitting a form. If the TYPE attribute is not specified then REQUEST is assumed.

A validation error handler will only be useful if placed inside the Application Template file, application.cfm.

TEMPLATE

The relative path to the file containing the error template. Note that this template can only include the error variables described below and cannot include CFML tags.

MAILTO

The email address of the administrator who should be notified of the error. This value is available to your custom error page using the MailTo property of the error object (e.g., #Error.MailTo#).

Note: The CFERROR tag is normally used to customize the error messages for all of the templates in an application. As a result, you generally embed it in the Application Template file, Application.cfm.

For more information about the Application Template file, refer to the Cold Fusion UserÆs Guide.

Error Template Variables

The error template specified in the TEMPLATE attribute may contain one or more error variables which will be substituted by Cold Fusion when an error is displayed. Beyond the specification of these variables, no other Cold Fusion tags (e.g., CFIF, CFSET, etc.) may be used in the template.

For custom error pages where TYPE="REQUEST" the following error variables are available:

Error Variable

Description

#Error.Diagnostics#

Detailed error diagnostics from the Cold Fusion Engine

#Error.MailTo#

Email address of administrator who should be notified (corresponds to the value set in the MAILTO attribute of CFERROR).

#Error.DateTime#

Date and time when the error occurred

#Error.Browser#

Browser which the client was running when the error occurred

#Error.RemoteAddress#

IP address of the remote client.

#Error.HTTPReferer#

Page from which the client accessed the link to the template where the error occurred

#Error.Template#

Template being executed when the error occurred.

#Error.QueryString#

URL query string of the client's request.

For custom error pages where TYPE="VALIDATION" the following error variables are available:

Attribute

Description

#Error.ValidationHeader#

Text for header of validation message

#Error.InvalidFields#

Unordered list of validation errors which occurred

#Error.ValidationFooter#

Text for footer of validation message

Example

<CFERROR TYPE="REQUEST" TEMPLATE="/error.htm" MAILTO="admin@world.b.free">