Adobe COLDFUSION 9 Manual page 253

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Developing CFML Applications
<cferror type="VALIDATION" template="validationerrorhandler.cfm">
• The ColdFusion default error mechanisms handle any errors that are not handled by the preceding techniques.
These mechanisms include the site-wide error handler that you specify in the ColdFusion Administrator and the
built-in default error pages.
These techniques let you include application-specific information, such as contact information or application or
version identifiers, in the error message, and let you display all error messages in the application in a consistent
manner. You use Application.cfc to develop sophisticated application-wide error-handling techniques, including
error-handling methods that provide specific messages, or use structured error-handling techniques.
Note: The
method catches errors that occur in the
onError
methods. It does not display messages to the user, however, because there is no request context. The
logs errors that occur when the session or application ends.
Handling server-side validation errors in the onError method
Server-side validation errors are actually ColdFusion exceptions; as a result, if your application uses an
method, this method gets the error and must handle it or pass it on to ColdFusion for handling.
To identify a server-side validation error, search the Arguments.Exception.StackTrace field for
coldfusion.filter.FormValidationException. You can then handle the error directly in your
the error so that either the ColdFusion default validation error page or a page specified by an
Application.cfc initialization code handles it.
Example: error Handling with the onError method
The following Application.cfc file has an
• If the error is a server-side validation error, the
which displays its standard validation error message.
• For any other type of exception, the
occurred and dumps the exception information. In this example, because you generate errors on the CFM page
only, and not in a Application.cfc method, the event name is always the empty string.
onSessionEnd
method that handles errors as follows:
onError
method throws the error for handling by ColdFusion,
onError
method displays the name of the event method in which the error
onError
Last updated 8/5/2010
and
application event
onApplicationEnd
onError
routine, or throw
onError
cferror
248
function
onError
tag in your

Advertisement

Table of Contents
loading

Table of Contents