cfthrow
419
Usage
Use this tag within a
cftry
block, to throw an error. The
cfcatch
block can access
accompanying information, as follows:
•
Message, with
cfcatch.message
•
Detail, with
cfcatch.detail
•
Error code, with
cfcatch.errorcode
To get more information, use
cfcatch.tagContext
. This array shows where control switches
from one page to another in the tag stack (for example,
cfinclude
,
cfmodule
).
To display the information displayed by
tagContext
: in the ColdFusion MX Administrator,
Debugging page, select Enable CFML Stack Trace.
Using the object parameter
To use this tag with the
object
parameter, you must first use a
cfobject
tag that specifies a valid Java exception class. For example, the following
cfobject
tag
defines an object, obj, of the exception class myException (which you must create in Java):
<cfobject
type="java"
action="create"
class="myException"
name="obj">
If your exception class has constructors that take parameters, such as a message, you can use the
special
init
method to invoke the constructor, as in the following line. If you do not need to
specify any constructor attributes, you can omit this step.
<cfset obj.init("You must save your work before preceding")>
You can then use the, the
cfthrow
statement to throw the exception as follows:
<cfthrow object=#obj#>
For more information on using Java objects in ColdFusion, see Chapter 37, “Integrating J2EE
and Java Elements in CFML Applications” in
ColdFusion MX Developer’s Guide
.
Example 1
<h3>cfthrow Example</h3>
<!--- Open a cftry block. --->
<cftry>
<!--- Define a condition upon which to throw the error. --->
<cfif NOT IsDefined("URL.myID")>
<!--- throw the error --->
<cfthrow message = "ID is not defined">
</cfif>
extendedInfo Optional
A custom error code that you supply.
object
Optional
Requires the value of the
cfobject
tag
name
attribute.
Throws a Java exception from a CFML tag.
This attribute is mutually exclusive with all other attributes of
this tag.
Attribute
Req/Opt Default
Description
Summary of Contents for COLFUSION MX 7 - INSTALLING AND USING COLDFUSION MX
Page 1: ...COLDFUSION MX7 CFML Reference...
Page 20: ...20 Chapter 1 Reserved Words and Variables...
Page 50: ...50 Chapter 2 ColdFusion Tags cfelse br Searching cfif cfloop cfif...
Page 101: ...cfdefaultcase 101 cfdefaultcase cfswitch cfoutput Your grade is grade cfoutput...
Page 115: ...cfdocumentsection 115 cfdocumentsection cfoutput cfdocument...
Page 411: ...cftable 411 cftable body html...
Page 515: ...Chr 515 maxlength 5 p input type Submit name input type RESET cfform...
Page 605: ...GetEncoding 605 WriteOutput The encoding is theEncoding cfscript cfif...
Page 629: ...GetProfileString 629 tr td input type Submit name Submit value Submit td td td tr table form...
Page 655: ...IIf 655 cfoutput IIf Hour Now GTE 12 DE It is afternoon or evening DE It is morning cfoutput b...
Page 664: ...664 Chapter 3 ColdFusion Functions cfelse h3 Conversion error h3 cfif...
Page 687: ...IsStruct 687 cfoutput cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Page 751: ...LSDateFormat 751 hr noshade cfoutput cfloop...
Page 861: ...StructFind 861 cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Page 903: ...Val 903 value Is the beginning numeric name form...
Page 932: ...932 Chapter 3 ColdFusion Functions...
Page 944: ...944 Chapter 4 ColdFusion MX Flash Form Style Reference...
Page 962: ...962 Chapter 5 Application CFC Reference...
Page 1054: ...1054 Chapter 6 ColdFusion MX Event Gateway Reference...