User Guide

Table Of Contents
Determining error-handling strategies 315
The missing error page can use CFML tags and variables. In particular, you can use the
CGI.script_name variable in text such as the following to identify the requested page:
<cfoutput>The page #Replace(CGI.script_name, "/", "")# is not available.<br>
Make sure that you entered the page correctly.<br>
</cfoutput>
(In this code, the Replace function removes the leading slash sign from the script name to make
the display more friendly.)
Handling form field validation errors
When you use server-side form field validation, the default validation error message describes the
error cause plainly and clearly. However, you might want to give the error message a custom look
or provide additional information such as service contact phone numbers and addresses. In this
case, use the
cferror tag with the Validation attribute in the Application.cfc initialization code
or on the Application.cfm page to specify your own validation error handler. The section
“Example of a validation error page” on page 320 provides an example of such a page. You can
also put form field validation error handling code in the Application.cfc
onError method.
Handling compiler exceptions
You cannot handle compiler exceptions directly on the page where they occur, because the
exception is caught before ColdFusion starts running the page code. You should fix all compiler
exceptions as part of the development process. Use the reported error message and the code
debugging techniques discussed in Chapter 18, “Debugging and Troubleshooting Applications,
on page 423 to identify and correct the cause of the error.
Compiler exceptions that occur on pages you access by using the
cfinclude or cfmodule tags
can actually be handled as runtime errors by surrounding the
cfinclude or cfmodule tag in a
cftry block. The compiler exception on the accessed page gets caught as a runtime error on the
base page. However, you should avoid this "solution" to the problem, as the correct method for
handling compiler errors is to remove them before you deploy the application.