Chapter 9. Error and Exception Handling
Structured exception handling lets you gracefully catch and handle exceptions that occur in your ColdFusion applications. Exceptions can include anything from a page timeout or a missing file to a database error or a problem with an external object. Using the techniques discussed in this chapter, you can build extremely robust exception-handling capabilities into your ColdFusion applications.
There are a number of different levels at which you can handle
exceptions and errors in a ColdFusion application. At the most basic
level, you can use the
CFCATCH tags in a template, to test for and trap
exceptions right where they occur. With the
CFTHROW tag, you can also define, throw, and catch
custom exceptions in your application.
Of course, catching every exception when it occurs can become quite
tedious, so ColdFusion provides a couple of different mechanisms for
handling exceptions at a higher level. With the
CFERROR tag, you can define generic error handlers
for different kinds of errors. The
CFERROR tag is
normally used in the
so that error handling occurs in the context of the Web Application
Framework. This ability to provide “catch all” error
handling for an application is quite convenient and powerful.
In addition, as of ColdFusion 4.5, a site administrator can set up error and exception handling at the server level, using the ColdFusion Administrator. We’ll cover all these different techniques for error ...