View comments | RSS feed
Contents > CFML Reference > ColdFusion Tags > cfabort Next

cfabort

Stops the processing of a ColdFusion page at the tag location. ColdFusion returns everything that was processed before the tag. The tag is often used with conditional logic to stop processing a page when a condition occurs.

Flow-control tags

<cfabort 
   showError = "error_message">

cfbreak, cfexecute, cfexit, cfif, cflocation, cfloop, cfswitch, cfthrow, cftry

Attribute

Req/Opt

Default

Description

showError

Optional

 

Error to display, in a standard ColdFusion error page, when tag executes.

When you use the cfabort and cferror tags together, the cfabort tag halts processing immediately; the cferror tag redirects output to a specified page.

If this tag does not contain a showError attribute value, processing stops when the tag is reached and ColdFusion returns the page contents up to the line that contains the cfabort tag.

When you use this tag with the showError attribute, but do not define an error page using cferror, page processing stops when the cfabort tag is reached. The message in showError displays to the client.

When you use this tag with the showError attribute and an error page using cferror, ColdFusion redirects output to the error page specified in the cferror tag.

<!--- this example shows the use of cfabort to stop processing. 
In the second example, where cfabort is used, the result never displays --->

<h3>Example A: Let the instruction complete itself</h3>
<!--- first, set a variable --->
<cfset myVariable = 3>
<!--- now, perform a loop that increments this value --->
<cfloop from = "1" to = "4" index = "Counter">
   <cfset myVariable = myVariable + 1>
</cfloop>

<cfoutput>
<p>   The value of myVariable after incrementing through the loop #Counter# times is:
#myVariable# </cfoutput> <h3>Example B: Use cfabort to halt the instruction</h3> <!--- reset the variable and show the use of cfabort ---> <cfset myVariable = 3> <!--- now, perform a loop that increments this value ---> <cfloop from = "1" to = "4" index = "Counter"> <!--- on the second time through the loop, cfabort ---> <cfif Counter is 2> <cfabort> <!--- processing is stopped, and subsequent operations are not carried out ---> <cfelse> <cfset myVariable = myVariable + 1> </cfif> </cfloop> <cfoutput> <p> The value of myVariable after incrementing through the loop
#counter# times is: #myVariable# </cfoutput>

Contents > CFML Reference > ColdFusion Tags > cfabort Next

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


lbryngel said on Feb 23, 2004 at 1:43 PM :
We are working to improve the examples in the ColdFusion reference pages. We propose to replace/add the current example on this page with the the following examples. If you have any comments on this example, add them to this page.

<!--- TO RUN EXAMPLE C:

- Comment out Example B code

- Uncomment Example C code

- Create error template from cferror tag examples in online CFML Tag Reference --->

<!---

<h3>Example C: Use cfabort to halt the instructions with showmessage attribute and cferror</h3>

<!--- reset the variable and show the use of cfabort --->

<cfset myVariable = 3>

<!--- now, perform a loop that increments this value --->

<cfloop from = "1" to = "4" index = "Counter">

<!--- on the second time through the loop, cfabort --->

<cfif Counter is 2>

<!--- Take out the cferror line to see cfabort error processed by CF error page --->

<cferror type="request" template="request_err.cfm">

<cfabort showerror="CFABORT has been called for no good reason">

<!--- processing is stopped, and subsequent operations are not carried out --->

<cfelse>

<cfset myVariable = myVariable + 1>

</cfif>

</cfloop>



<cfoutput>

<p> The value of myVariable after incrementing through the loop#counter# times is: #myVariable#

</cfoutput>

--->
fifthtime said on May 11, 2004 at 9:39 AM :
this tag is not working in 6.1 and I am getting no help.

<CFIF IsNumeric(memid) IS "No">
<CFABORT SHOWERROR = "Illegal Member Number.">
</CFIF>

gives me error
Error occurred while processing request.
Illegal Member Number.


The error occurred in D:\HTMLSERSUSERWEB3\HTMLLISTRESULTS1.CFM: LINE 55
CALLED FROM D:\HTMLSERSUSERWEB3\HTMLLISTRESULTS1.CFM: LINE 53
CALLED FROM D:\HTMLSERSUSERWEB3\HTMLLISTRESULTS1.CFM: LINE 47
CALLED FROM D:\HTMLSERSUSERWEB3\HTMLLISTRESULTS1.CFM: LINE 1

53 : <CFELSE>
54 : <CFIF ISNUMERIC(MEMID) IS "NO">
55 : <CFABORT SHOWERROR = "ILLEGAL MEMBER NUMBER.">
56 : </CFIF>
KIRAGANJEFF SAID ON SEP 27, 2004 AT 8:47 AM :
FIFTHTIME:

I BELIEVE THAT WOULD BE THE EXPECTED BEHAVIOR, UNLESS YOU HAVE A CFERROR TEMPLATE DEFINED.
HERAKLES_UK1 SAID ON OCT 19, 2004 AT 1:43 AM :
/ME SNIGGERS QUIETLY...

&NBSP;

RSS FEED | SEND ME AN E-MAIL WHEN COMMENTS ARE ADDED TO THIS PAGE | COMMENT REPORT

CURRENT PAGE: HTTP://LIVEDOCS.ADOBE.COM/COLDFUSION/6.1/HTMLDOCS/TAGS-PT1.HTM