Macromedia coldfusion 4.5-cfml language reference ユーザーズマニュアル
Chapter 1: ColdFusion Tags
219
Note
In order to see the information displayed by TagContext, use the
ColdFusion Administrator to enable the CFML stack trace.Under
Debugging in the ColdFusion Administrator, choose the checkbox next to
"Enable CFML stack trace. "
ColdFusion Administrator to enable the CFML stack trace.Under
Debugging in the ColdFusion Administrator, choose the checkbox next to
"Enable CFML stack trace. "
Example
<!--- This example shows the use of CFTHROW. --->
<HTML>
<HEAD>
<TITLE>
CFTHROW Example
</TITLE>
</HEAD>
<TITLE>
CFTHROW Example
</TITLE>
</HEAD>
<BASEFONT FACE="Arial, Helvetica" SIZE=2>
<BODY bgcolor="#FFFFD5">
<H3>CFTHROW Example</H3>
<!--- open a CFTRY block --->
<CFTRY>
<!--- define a condition upon which to throw
the error --->
<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>
<!--- perform the error catch --->
<CFCATCH TYPE="application">
<!--- display your message --->
<CFCATCH TYPE="application">
<!--- display your message --->
<H3>You’ve Thrown an <B>Error</B></H3>
<CFOUTPUT>
<!--- and the diagnostic feedback from the
application server --->
<P>#CFCATCH.message#</P>
<!--- and the diagnostic feedback from the
application server --->
<P>#CFCATCH.message#</P>
<P>The contents of the tag stack are:</P>
<CFLOOP index=i from=1 to = #ArrayLen(CFCATCH.TAGCONTEXT)#>
<CFLOOP index=i from=1 to = #ArrayLen(CFCATCH.TAGCONTEXT)#>
<CFSET sCurrent = #CFCATCH.TAGCONTEXT[i]#>
<BR>#i# #sCurrent["ID"]#
(#sCurrent["LINE"]#,#sCurrent["COLUMN"]#) #sCurrent["TEMPLATE"]#
</CFLOOP>
</CFOUTPUT>
</CFCATCH>
</CFCATCH>
</CFTRY>
</BODY>
</HTML>