Using The Cfthrow Tag - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Code
<cfcatch type="Database">
<h1>Database Error</h1>
<cfoutput>
<ul>
<li><b>Message:</b> #cfcatch.Message#
<li><b>Native error code:</b>
#cfcatch.NativeErrorCode#
<li><b>SQLState:</b> #cfcatch.SQLState#
<li><b>Detail:</b> #cfcatch.Detail#
</ul>
</cfoutput>
<cfset errorCaught = "Database">
</cfcatch>
<cfcatch type="Any">
<cfoutput>
<hr>
<h1>Other Error: #cfcatch.Type#</h1>
<ul>
<li><b>Message:</b> #cfcatch.message#
<li><b>Detail:</b> #cfcatch.Detail#
</ul>
</cfoutput>
<cfset errorCaught = "General Exception">
</cfcatch>
</body>
</html>
</cftry>

Using the cfthrow tag

You can use the
you specify any or all of the following information:
Attribute
type
message
detail
errorCode
extendedInfo
All of these values are optional. You access the attribute values in
type error pages by prefixing the attribute with either
cfcatch.extendedInfo
values in the Message pane and the remaining values in the Error Diagnostic Information pane.
tag to raise your own, custom exceptions. When you use the
cftry
Meaning
The type of error. It can be a custom type that has meaning only to your
application, such as InvalidProductCode. You can also specify Application, the
default type. You cannot use any of the predefined ColdFusion error types, such
as Database or MissingTemplate.
A brief text message indicating the error.
A more detailed text message describing the error.
An error code that is meaningful to the application. This field is useful if the
application uses numeric error codes.
Any additional information of use to the application.
. The default ColdFusion error handler displays the message and detail
Description
Handles exceptions thrown when accessing a
database.
Displays
cfcatch
ColdFusion basic error message, the error code
and SQL state reported by the databases
system, and the detailed error message.
Sets the
errorCaught
error type.
Handles any other exceptions generated in the
block.
cftry
Since the error can occur after information has
displayed (in this case, the contents of the
include file), draws a line before writing the
message text.
Displays the ColdFusion basic and detailed error
message.
Sets the
errorCaught
error type.
Ends the HTML page, then the
cfcatch
or
cfcatch
error
Handling runtime exceptions with ColdFusion tags
variables, including the
variable to indicate the
variable to indicate the
block.
cftry
cfthrow
blocks and Exception
, as in
tag,
307

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents