Whatever message this page gives is out now! Go check it out!

cferror

Last update:
May 18, 2026

Description

Displays a custom HTML page when an error occurs. This lets you maintain a consistent look and feel among an application's functional and error pages.

Category

Syntax

<cferror 
 template = "template path" 
 type = "exception|validation|request" 
 exception = "exception type" 
 mailTo = "e-mail address">
Note: You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.

See also

cfrethrowcfthrowcftryHandling Errors in the Developing ColdFusion Applications.

History

ColdFusion MX: Deprecated the monitor option of the exception attribute. It might not work, and might cause an error, in later releases.

Attributes

Attribute
Req/Opt
Default
Description
template
Required
Relative path to the custom error page. (A ColdFusion page was formerly called a template.)
type
Required
Type of error that the custom error page handles. The type also determines how ColdFusion handles the error page. For more information, see Specifying a custom error page in Specifying custom error messages with the cferror tag in the Developing ColdFusion Applications.
  • exception: an exception of the type specified by the exception attribute.
  • validation: errors recognized by server-side type validation.
  • request: any encountered error.
exception
Optional
any
Type of exception that the tag handles:
  • application: application exceptions.
  • database: database exceptions.
  • template: ColdFusion page exceptions.
  • security: security exceptions.
  • object: object exceptions.
  • missingInclude: missing include file exceptions.
  • expression: expression exceptions.
  • lock: lock exceptions.
  • custom_type: developer-defined exceptions, defined in the cfthrow tag.
  • any: all exception types. For more information on exception types, see cftry.
mailTo
Optional
An e-mail address. This attribute is available on the error page as the variable error.mailto. ColdFusion does not automatically send anything to this address.

Usage

Use this tag to provide custom error messages for pages in an application. This lets you maintain a consistent look and feel within the application, even when errors occur. You generally embed this tag in your Application CFC or Application.cfm file to specify error-handling responsibilities for an entire application. You must put it in one of these files if you specify type="validation"; ColdFusion ignores it on any other page. The cftry and cfcatch tags provide a more interactive way to handle ColdFusion errors within a ColdFusion page than the cferror tag, but the cferror tag is a good safeguard against general errors. To ensure that error pages display successfully, avoid using the cfencode utility to encode pages that include the cferror tag.

Page types

The following table describes the types of errors you can specify and code you can use on the pages that handle these error type:
Page type
Description
Use
Exception
Dynamically invoked by the CFML language processor when it detects an unhandled exception condition.Uses the full range of CFML tags. Error variables must be in cfoutput tags.
Can handle specific exception types or display general information for exceptions.
Request
Includes the error variables described in the Error variables section. Cannot include CFML tags, but you can display values of the error variables by enclosing them in number signs (#), as in #error.MailTo#.
Use as a backup error handler to other error handling methods, including exception type.
Validation
Handles data input validation errors that occur when submitting a form that uses hidden form-field validation or onSubmit validation. Cannot include CFML tags, but you can display values of the error variables by enclosing them in number signs (#), as in #Error.InvalidFields#.Specify the validation error handler in the Application.cfc or Application.cfm file.
Handles hidden form-field or onSubmit format validation errors only.

Error variables

The exception-handling page specified in the cferror tag template attribute contains one or more error variables. ColdFusion substitutes the value of the error variable when an error displays.

The following table lists error variables:
Page type
Error variable
Description
Validation only
error.validationHeader
Validation message header text.
error.invalidFields
Unordered list of validation errors.
error.validationFooter
Validation message footer text.
Request and Exception
error.diagnostics
Detailed error diagnostics from ColdFusion.
error.mailTo
E-mail address (same as value in cferror.MailTo).
error.dateTime
Date and time when error occurred.
error.browser
Browser that was running when error occurred.
error.remoteAddress
IP address of remote client.
error.HTTPReferer
Page from which client accessed link to page where error occurred.
error.template
Page executing when error occurred.
error.generatedContent
The content generated by the page up to the point where the error occurred.
error.queryString
URL query string of client's request.
Exception only
error.message
Error message associated with the exception.
error.rootCause
The root cause of the exception. This structure contains the information that is returned by a cfcatch tag. For example, for a database exception, the SQL statement that caused the error is in the error.RootCause.Sql variable. For Java exceptions, this variable contains the Java servlet exception reported by the JVM as the cause of the "root cause" of the exception.
error.tagContext
Array of structures containing information for each tag in the tag stack. The tag stack consists of each tag that is currently open.
error.type
Exception type.
Note: If type = "exception", you can substitute the prefix cferror for Error; for example, cferror.diagnostics, cferror.mailTo, or cferror.dateTime.

Example

<h3>cferror Example</h3> 
 
 <!--- Example of cferror call within a page. 
 NOTE: If you use cferror type="VALIDATION" you MUST put it in 
 Application.cfc or Application.cfm ---> 
 <cferror type = "REQUEST" 
 template = "request_err.cfm" 
 mailTo = "admin@mywebsite.com"> 
 <!--- This query calls a non-existent datasource, triggering an error to be handled. ---> 
 <cfquery name="testQuery" datasource="doesNotExist"> 
 select * from nothing 
 </cfquery> 
 
 <!--- Example of the page (request_err.cfm) to handle this error. ---> 
 <html> 
 <head> 
 <title>We're sorry -- An Error Occurred</title> 
 </head> 
 <body> 
 <h2>We're sorry -- An Error Occurred</h2> 
 <p> 
 If you continue to have this problem, please contact #error.mailTo# 
 with the following information:</p> 
 <p> 
 <ul> 
 <li><b>Your Location:</b> #error.remoteAddress# 
 <li><b>Your Browser:</b> #error.browser# 
 <li><b>Date and Time the Error Occurred:</b> #error.dateTime# 
 <li><b>Page You Came From:</b> #error.HTTPReferer# 
 <li><b>Message Content</b>: 
 <p>#error.diagnostics#</p> 
 </ul>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page