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 Application.cfm template,
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, 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 and exception handling ...