CFERROR | |||||||||||||||||||||||||||||||||||||||||
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 | |||||||||||||||||||||||||||||||||||||||||
Exception handling tags, Extensibility tags, Application framework tags | |||||||||||||||||||||||||||||||||||||||||
Syntax<cferror type = "a type" template = "template_path" mailTo = "email_address" exception = "exception_type"> |
|||||||||||||||||||||||||||||||||||||||||
See also | |||||||||||||||||||||||||||||||||||||||||
cfrethrow, cfthrow, cftry | |||||||||||||||||||||||||||||||||||||||||
History | |||||||||||||||||||||||||||||||||||||||||
ColdFusion MX: Deprecated the monitor option of the exception attribute. It might not work, and might cause an error, in later releases. | |||||||||||||||||||||||||||||||||||||||||
Usage | |||||||||||||||||||||||||||||||||||||||||
Use this tag to provide custom error messages for pages in an application. You generally embed this tag in the Application.cfm file. For more information, see Chapter 14, "Handling Errors," in Developing ColdFusion MX Applications. | |||||||||||||||||||||||||||||||||||||||||
To ensure that error pages display successfully, avoid using the cfencode tag 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.
|
|||||||||||||||||||||||||||||||||||||||||
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:
In exception error handling pages, you can access the error variables that are also available to the cfcatch tag. See cfcatch for a description of these variables. To use these variables, prefix them with "cferror."
|
|||||||||||||||||||||||||||||||||||||||||
Example<h3>cferror Example</h3> <p>cferror lets you display custom HTML pages when errors occur. This lets you maintain a consistent look and feel within the application even when errors occur. No CFML can be displayed in the pages, except specialized error variables. <p>cftry/cfcatch is a more interactive way to handle CF errors within a CF page than cferror, but cferror is a good safeguard against general errors. <p>You can also use cferror within Application.cfm to specify error handling responsibilities for an entire application. <!--- Example of cferror call within a page ---> <cferror type = "REQUEST" template = "request_err.cfm" mailTo = "admin@mywebsite.com"> <!--- Example of the page 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> |
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 Chapter 14, "Specifying a custom error page," in Developing ColdFusion MX Applications.
|
TEMPLATE | |
Required | |
Relative path to the custom error page. (A ColdFusion page was formerly called a template.) |
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. |
EXCEPTION | |
Optional | |
Default value: "Any"
Type of exception that the tag handles:
For more information on exception types, see cftry. |