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:
cferror
tag to specify ColdFusion pages to handle specific types of errors.cftry
, cfcatch
, and cfthrow
tags to catch and handle exception errors directly.The remaining sections in this chapter provide the following information:
cferror
tag to specify error-handling pagesBefore you can effectively managee ColdFusion errors, you must understand the error types and how ColdFusion handles them.
ColdFusion errors can help you to debug your application and provide feedback to users. There are several types of errors in ColdFusion:
cfthrow
or cfabort
tagsThe 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 acferror 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 Ifa 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 |