Adobe COLDFUSION 9 Manual page 281

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Developing CFML Applications
• How to use the
cferror
• How to log errors
• How to handle ColdFusion exceptions
Note: Information about using the
statements. The general discussion of exception handling applies to tags and CFScript statements. However, the
catch
code that you use and the information available in CFScript differs from the information in the tags. For more
information on handling exceptions in CFScript, see
Understanding errors
You can look at errors in many ways; 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, as follows:
About error causes and recovery
Errors can have many causes. Depending on the cause, the error can 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, are 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.
Errors such as validation errors, for which the application cannot continue processing the request, but can provide an
error-specific response, can also be considered recoverable. For example, an error that occurs when a user enters text
where a number is required can be considered recoverable, because the application can recognize the error and
redisplay the data field with a message providing information about the cause of the error and telling the user to reenter
the data.
Some types of errors are recoverable in some, but not all circumstances. For example, your application can retry a
request following a time-out error, but it must also be prepared for the case where the request always times out.
Error causes fall in the broad categories listed in the following table:
Category
Description
Program errors
Can be in the code syntax or the program logic. The ColdFusion compiler identifies and reports program syntax
errors when it compiles CFML into Java classes. Errors in your application logic are harder to locate. For
information on debugging tools and techniques, see
page 378.
Unlike ColdFusion syntax errors, SQL syntax errors are only caught at runtime.
Data errors
Are typically user data input errors. You use validation techniques to identify errors in user input data and enable
the user to correct the errors.
System errors
Can come from a variety of causes, including database system problems, time-outs due to excessive demands on
your server, out-of-memory errors in the system, file errors, and disk errors.
Although these categories do not map completely to the way ColdFusion categorizes errors they provide a useful way
of thinking about errors and can help you in preventing and handling errors in your code.
ColdFusion error types
Before you can effectively manage ColdFusion errors, you must understand how ColdFusion classifies and handles
them. ColdFusion categorizes errors as detailed in the following table:
tag to specify error-handling pages
and
cftry
cfcatch
"Handling errors in
Last updated 8/5/2010
tags is provided, but not the equivalent CFScript
UDFs" on page 166.
"Debugging and Troubleshooting
276
and
try
Applications" on

Advertisement

Table of Contents
loading

Table of Contents