About 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. You can use any of the following error-management techniques:
•
Specify custom pages for ColdFusion to display in each of the following cases:
when a ColdFusion page is missing (the Missing Template Handler page)
when an otherwise-unhandled exception error occurs during the processing of a page (the
Site-wide Error Handler page)
You specify these pages on the ColdFusion MX Administrator Server Settings page. For more
information on specifying custom error pages in the Administrator, see the ColdFusion MX
Administrator Help.
•
Use the
cferror
•
Log errors. ColdFusion logs certain errors by default. You can use the
errors.
•
Use the
cftry
directly on the page where they occur.
•
In CFScript, use the
The remaining sections in this chapter provide the following information:
•
The basic building blocks for understating types of ColdFusion errors and how ColdFusion
handles them
•
How to use the
•
How to log errors
•
How to handle ColdFusion exceptions
Note: This chapter discusses using the
and
statements. The general discussion of exception handling in this chapter applies to tags
catch
and CFScript statements. However, the code that you use and the information available in CFScript
differs from those in the tags. For more information on handling exceptions in CFScript, see
10, "Handling errors in UDFs," on page 212
Understanding errors
There are many ways to look at errors; for example, you can look at errors by their causes. You can
also look at them by their effects, particularly by whether your application can recover from them.
You can also look at them the way ColdFusion does. The following sections discuss these ways of
looking at errors.
About error causes and recovery
Errors can have many causes. Depending on the cause, the error might be recoverable. A
recoverable error is one for which your application can identify the error cause and take action on
the problem. Some errors, such as time-out errors, might be recoverable without indicating to the
user that an error was encountered. An error for which a requested application page does not exist
is not recoverable, and the application can only display an error message.
286
Chapter 14: Handling Errors
tag to specify ColdFusion pages to handle specific types of errors.
,
,
, and
cfcatch
cfthrow
and
try
catch
tag to specify error-handling pages
cferror
cftry
tags to catch and handle exception errors
cfrethrow
statements to handle exceptions.
and
tags, but not the equivalent CFScript
cfcatch
.
tag to log other
cflog
try
Chapter
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers