Adobe ColdFusion 8

How ColdFusion handles errors

The following sections describe briefly how ColdFusion handles errors. The rest of this chapter expands on this information.

Missing template errors

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.

Form field validation errors

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:

  1. If the Application CFC (Application.cfc) has an onError event handler method, ColdFusion calls the method.
  2. If the Application.cfc initialization code or the Application.cfm page has a cferror that specifies a Validation error handler, ColdFusion displays the specified error page.
  3. Otherwise, it displays the error information in a standard format that consists of a default header, a bulleted list describing the errors, and a default footer.

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.

Compiler exception errors

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 the error occurs on a page that is accessed by a cfinclude or cfmodule tag, or on a custom tag page that you access using the cf_ notation, ColdFusion handles it as a runtime exception in the page that accesses the tag. For a description of how these errors are handled, see the next section, "Runtime exception errors."
  • If the error occurs directly on the requested page, and the Administrator Settings Site-wide Error Handler field specifies an error handler page, ColdFusion displays the specified error page. Otherwise, ColdFusion reports the error using the standard error message format described in Error messages and the standard error format.

Runtime exception errors

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.