Creating an error application page

The following table lists the rules and considerations that apply to error application pages:

Type

Considerations

Validation

  • Cannot use CFML tags.

  • Can use HTML tags.

  • Can use the Error.InvalidFields, Error.validationHeader, and Error.validationFooter variables by enclosing them with number signs (#).

  • Cannot use any other CFML variables.

Request

  • Cannot use CFML tags.

  • Can use HTML tags.

  • Can use nine CFML error variables, such as Error.Diagnostics, by enclosing them with number signs.

  • Cannot use other CFML variables.

Exception

  • Can use full CFML syntax, including tags, functions, and variables.

  • Can use nine standard CFML Error variables and cfcatch variables. Use either Error or cferror as the prefix for both types of variables.

  • Can use other application-defined CFML variables.

  • To display any CFML variable, use the cfoutput tag.

The following table describes the variables available on error pages: Exception error pages can also use all of the exception variables listed in the section Exception information in cfcatch blocks. To use these variables, replace the cfcatch prefix with cferror or error. For example, to use the exception message in an error page, refer to it as error.message.

In general, production Exception and Request pages should not display detailed error information, such as that supplied by the error.diagnostics variable. Typically, Exception pages e-mail detailed error information to an administrative address or log the information using the cflog tag instead of displaying it to the user. For more information on using the cflog tag, see Logging errors with the cflog tag.

Example of a request error page

The following example shows a custom error page for a request error:

<html> 
<head> 
<title>Products - Error</title> 
</head> 
<body> 
 
<h2>Sorry</h2> 
 
<p>An error occurred when you requested this page.</p> 
<p>Please send e-mail with the following information to #error.mailTo# to report 
    this error.</p> 
 
<table border=1> 
<tr><td><b>Error Information</b> <br> 
    Date and time: #error.DateTime# <br> 
    Page: #error.template# <br> 
    Remote Address: #error.remoteAddress# <br> 
    HTTP Referer: #error.HTTPReferer#<br> 
</td></tr></table> 
 
<p>We apologize for the inconvenience and will work to correct the problem.</p> 
</body> 
</html>

Example of a validation error page

The following example shows a simple custom error page for a validation error:

<html> 
<head> 
<title>Products - Error</title> 
</head> 
<body> 
 
<h2>Data Entry Error</h2> 
 
<p>You failed to correctly complete all the fields 
in the form. The following problems occurred:</p> 
 
#error.invalidFields# 
 
</body> 
</html>