Handling Compiler Exceptions; Handling Runtime Exceptions - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

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
on page 389
to identify and correct the cause of the error.
Compiler exceptions that occur on pages you access by using the
can actually be handled as runtime errors by surrounding the
block. The compiler exception on the accessed page gets caught as a runtime error on the
cftry
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.

Handling runtime exceptions

You have many choices for handling exceptions, and the exact path you take depends on your
application and its needs. The following table provides a guide to selecting an appropriate
technique:
Technique
cftry
cferror
with
exception-
specific error
handler pages
with a
cferror
Request error
page
Site-wide error
handler page
Chapter 18, "Debugging and Troubleshooting Applications,"
Use
Place
blocks around specific code sections where exceptions can be
cftry
expected and you want to handle those exceptions in a context-specific manner;
for example, if you want to display an error message that is specific to that code.
Use
blocks where you can recover from an exception. For example, you
cftry
can retry an operation that times out, or access an alternate resource. You can
also use the
tag to continue processing where a specific exception will not
cftry
harm your application; for example, if a missing resource is not required.
For more information, see
on page
299.
Use the
tag to specify error pages for specific exception types. These
cferror
pages cannot recover from errors, but they can provide the user with information
about the error's cause and steps that they can take to prevent the problem.
For more information, see
on page
294.
Use the
tag to specify a Request error handler that provides a
cferror
customized, application-specific message for unrecoverable exceptions. Put the
tag in the Application.cfm page to make it apply to all pages in an application.
A Request error page cannot use CFML tags, but it can display error variables.
As a result, you can use it to display common error information, but you cannot
provide error-specific instructions. Typically, Request pages display error
variable values and application-specific information, including support contact
information.
For example code, see
Specify a site-wide error handler in the Administrator to provide consistent
appearance and contents for all otherwise-unhandled exceptions in all
applications on your server.
Like the Request page, the site-wide error handler cannot perform error
recovery. However, it can include CFML tags in addition to the error variables.
Because a site-wide error handler prevents ColdFusion from displaying the
default error message, it allows you to limit the information reported to users. It
also lets you provide all users with default contact information or other
instructions.
cfinclude
"Handling runtime exceptions with ColdFusion tags"
"Specifying custom error messages with cferror"
"Example of a request error page" on page
Determining error-handling strategies
or
cfinclude
cfmodule
or
tag in a
cfmodule
297.
tags
293

Advertisement

Table of Contents
loading
Need help?

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

This manual is also suitable for:

Coldfusion mx

Table of Contents