Using Cftry: An Example - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Property variable
cfcatch.Sql
cfcatch.queryError
cfcatch.where
Expression exceptions
The following variable is only available for Expression exceptions:
Property variable
cfcatch.ErrNumber
Locking exceptions
The following additional information is available for exceptions related to errors that occur in
tags:
cflock
Property variable
cfcatch.lockName
cfcatch.lockOperation
Missing include exceptions
The following additional variable is available if the error is caused by a missing file specified by a
tag:
cfinclude
Property variable
cfcatch.missingFileName

Using cftry: an example

The following example shows the
used in many of the examples in this book and a sample included file,
If an exception occurs during the
switches to the
cfcatch type
statement after the
Similarly, the
cfcatch type
tag.
cfinclude
<!--- Wrap code you want to check in a cftry block --->
<cfset EmpID=3>
<cfparam name="errorCaught" default="">
<cftry>
<cfquery name="test" datasource="CompanyInfo">
SELECT Dept_ID, FirstName, LastName
FROM Employee
WHERE Emp_ID=#EmpID#
Description
The SQL statement sent to the data source.
The error message as reported by the database driver.
If the query uses the
value pairs.
Description
An internal expression error number, valid only when
type="Expression"
Description
The name of the affected lock. This is set to "anonymous" if the lock
name is unknown.
The operation that failed. This is set to "unknown" if the failed
operation is unknown.
Description
The name of the missing file.
and
cftry
cfquery
=
"Database"
block, once the
cftry
=
"MissingInclude"
cfqueryparam
.
tags. It uses the CompanyInfo data source
cfcatch
statement's execution, the application page flow
exception handler. It then resumes with the next
=
cfcatch type
"Database"
block handles exceptions raised by the
Handling runtime exceptions with ColdFusion tags
tag, query parameter name-
includeme.cfm.
handler completes.
303

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents