Enables the display of customized HTML pages when errors occur. This lets you maintain a consistent look and feel within your application, even when errors occur.
<cferror type = "request" or "validation" or
"monitor" or "exception"
template = "template_path"
mailTo = "email_address"
exception = "exception_type">
cfrethrow, cfthrow, cftry cfcatch
Use the cferror tag to customize error messages for all the pages in an application. You generally embed the cferror tag in the Application.cfm file. For more information, see Advanced ColdFusion Administration.
To ensure that error pages display successfully, do not use the cfencode utility to encode pages that include cferror.
The following table describes the template to use for each type of error.
The exception-handling template specified in the template attribute of the cferror tag contains one or more error variables. ColdFusion substitutes the value of the error variable when an error displays.
The following table lists the error variables:
|
Note If you specify |
<!--- This example shows the use of cferror. --->
<html>
<head>
<title>cferror Example</title>
</head>
<body>
<H3>cferror Example</H3>
<P>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. Note that no CFML
can be displayed in the resulting templates except
for the specialized error variables.
<P>cftry/cfcatch provides a more interactive way to
handle your CF errors within a CF template than cferror,
but cferror is still a good safeguard against general
errors.
<P>You can also use cferror within the Application.cfm
to specify error handling responsibilities for an entire
application.
<!--- Example of cferror call within a template --->
<cferror type = "REQUEST"
template = "request_err.cfm"
mailTo = "admin@mywebsite.com">
<!--- Example of the template to handle this error --->
<!---
<html>
<head>
<title>We're sorry -- An Error Occurred</title>
</head>
<body>
<UL>
<cfoutput>
<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>: <BR><HR width = 50%>
<P>#error.diagnostics#<HR width = 50%><P>
<LI><B>Please send questions to:</B>
<a href = "mailto:#error.mailTo#">#error.mailTo#</A>
</cfoutput>
</UL>
</body>
</html> --->