Error Handling in ColdFusion

By default, ColdFusion generates its own error messages when it encounters errors. In addition, it provides a variety of tools and techniques for you to customize error information and handle errors when they occur, including the following techniques:

The remaining sections in this chapter provide the following information:

Understanding ColdFusion errors

Before you can effectively managee ColdFusion errors, you must understand the error types and how ColdFusion handles them.

ColdFusion error types

ColdFusion errors can help you to debug your application and provide feedback to users. There are several types of errors in ColdFusion:

How ColdFusion handles errors

The following pseudo-code program illustrates how ColdFusion handles errors. The rest of this expands on this outline:

Case missing template error
  ColdFusion displays either a standard error page or an error page
  that you specify as the Missing Template Handler in the Administrator
  Server Settings Missing Template Handler field.
Case validation error
  If cferror in application.cfm specifies a validation error handler
    Use error page specified by cferror
  Else
    Use standard CFML validation error message format
  Endif
Case exception error
  If a cferror tag in aplication.cfm specifies a monitor error handler
      for the exception type
    Use the Monitor error page; when the page exits continue handling
    the error as follows
  Endif
  If code with error is inside a cftry tag and the exception type is
       specified in a cfcatch tag (see Note)
    Execute code in cfcatch tag
  Else If a cferror tag specifies an exception error handler for the
      exception type
    Use error page specified by cferror
  Else If Administrator Settings Site-wide Error Handler field
      specifies an error handler page
    Use custom error page
  Else If a cferror tag specifies an request error handler
    Use error page specified by cferror
  Else
      Use standard CFML error message
  Endif

Note

If the current tag is nested inside other tags, the CFML processor checks the entire stack of open tags until it finds a suitable cftry/cfcatch combination or reaches the end of the stack.