The following sections describe briefly how ColdFusion handles errors. The rest of this chapter expands on this information.
If a user requests a page that the ColdFusion cannot find, and the Administrator Server Settings Missing Template Handler field specifies a Missing Template Handler page, ColdFusion uses that page to display error information. Otherwise, it displays a standard error message.
When a user enters invalid data in an HTML tag that uses onServer or hidden form field server-side data validation ColdFusion does the following:
For more information on using hidden form field validation, see Validating Data. For more information on Application.cfc, see Designing and Optimizing a ColdFusion Application.
If ColdFusion encounters a compiler exception, how it handles the exception depends on whether the error occurs on a requested page or on an included page:
If ColdFusion encounters a runtime exception, it does the action for the first matching condition in the following table:
Condition |
Action |
---|---|
The code with the error is inside a cftry tag and the exception type is specified in a cfcatch tag. |
Executes the code in the cfcatch tag. If the cftry block does not have a cfcatch tag for this error, tests for an appropriate cferror handler or site-wide error handler. |
The ColdFusion application has an Application.cfc with an onError method |
Executes the code in the onError method. For more information on using the onError method, see Handling errors in Application.cfc. |
A cferror tag specifies an exception error handler for the exception type. |
Uses the error page specified by the cferror tag. |
The Administrator Settings Site-wide Error Handler field specifies an error handler page. |
Uses the custom error page specified by the Administrator setting. |
A cferror tag specifies a Request error handler. |
Uses the error page specified by the cferror tag. |
The default case. |
Uses the standard error message format |
For example, if an exception occurs in CFML code that is not in a cftry block, and Application.cfc does not have an onError method, but a cferror tag specifies a page to handle this error type, ColdFusion uses the specified error page.