MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 313

Developing coldfusion mx applications
Table of Contents

Advertisement

Code
<cfcatch type = "Any">
<cfrethrow>
</cfcatch>
</cftry>
<cfcatch Type = "Any">
<h2>Sorry</h2>
<p>An unexpected error happened in
processing
your user inquiry.
Please report the following to
technical support:</p>
<cfoutput>
Type: #cfcatch.Type#
Message: #cfcatch.Message#
</cfoutput>
<cfexit method = "exittag">
</cfcatch>
</cftry>
</cfif>
Testing the code
To test the various ways errors can occur and be handled in this example, try the following:
In the calling page, change the attribute name to any other value; for example, My Attrib.
Then change it back.
In the first
cfquery
NoDatabase.
With an invalid first data source name, change the data source in the second
CompanyInfo.
Insert
tags throwing custom exculpations in various places in the code and observe
cfthrow
the effects.
tag, change the data source name to an invalid data source; for example,
Handling runtime exceptions with ColdFusion tags
Description
In the second try block, catches any errors other
exceptions and rethrows them up to the
outermost try block.
Ends the second try block.
In the outermost try block, handles any
exceptions by displaying an error message that
includes the exception type and the exception's
error message. Because there was no code to
try that is not also in a nested try block, this
tag handles only errors that are rethrown
cfcatch
from the nested blocks.
Exits the custom tag and returns to the calling
page.
Ends the catch block, try block, and initial
block.
cfif
tag to
cfquery
313

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents