home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cfthrow.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.0 KB  |  48 lines

  1. <!--- This example shows how to use CFTHROW to
  2.       create an error --->
  3.  
  4. <HTML>
  5.  
  6. <HEAD>
  7. <TITLE>
  8. CFTHROW Example
  9. </TITLE>
  10. </HEAD>
  11.  
  12. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  13.  
  14. <BODY  bgcolor="#FFFFD5">
  15.  
  16. <H3>CFTHROW Example</H3>
  17.  
  18. <!--- open a CFTRY block --->
  19. <CFTRY>
  20. <!--- define a condition upon which to throw
  21.       the error --->
  22.     <CFIF NOT IsDefined("URL.myID")>
  23. <!--- throw the error --->
  24.         <CFTHROW MESSAGE="ID is not defined">
  25.     </CFIF>
  26.  
  27. <!--- perform the error catch --->
  28. <CFCATCH TYPE="application">
  29. <!--- display your message --->
  30.     <H3>You've Thrown an <B>Error</B></H3>
  31. <CFOUTPUT>
  32. <!--- and the diagnostic feedback from the
  33. application server --->
  34.     <P>#CFCATCH.message#</P>
  35.     <P>The contents of the tag stack are:</P>
  36.     <CFLOOP index=i from=1 to = #ArrayLen(CFCATCH.TAGCONTEXT)#>
  37.           <CFSET sCurrent = #CFCATCH.TAGCONTEXT[i]#>
  38.               <BR>#i# #sCurrent["ID"]# (#sCurrent["LINE"]#,#sCurrent["COLUMN"]#) #sCurrent["TEMPLATE"]#
  39.     </CFLOOP>        
  40. </CFOUTPUT>
  41. </CFCATCH>
  42.  
  43. </CFTRY>
  44.  
  45. </BODY>
  46.  
  47. </HTML>       
  48.