Spec-Zone.ru › ColdFusion

cfabort

Stops the processing of a CFML page at the tag location. CFML 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.

<cfabort>

abort;

  • CF
  • Lucee
  • BL 1.0.0+
  • See Also: cferror cfthrow cfexit

    Attribute Reference

    showerror string

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

    attributecollection string

    You can specify this tag's attributes in an attributeCollection whose value is a structure. Specify the structure name in the attributeCollection and use the tag‚ attribute names as structure keys.

    Compatibility

    BoxLang:

    Version 1.0.0+ <bx:abort> in BoxLang files.

    Examples
    Sample code using the cfabort tag

    Example of using abort() to stop processing after an error occurs

    In this example we demonstrate using the abort() function to stop any further processing after we deliberately call a non-existent function.

    try {
    	// make a call to a non-existent function
    	firstName = userService.getUserById( 1 ).getFirstName();
    // catch any errors    
    } catch ( any e ) {
    	// dump the error to the browser
    	writeDump( e );
    	// abort further processing
    	abort;
    }

    Expected Result: Error page: Variable USERSERVICE is undefined.

    Example of using <cfabort> to stop processing after an error occurs

    In this example we demonstrate using the tag to stop any further processing after we deliberately call a non-existent function.

    <cftry>
    	<!--- make a call to a non-existent function --->
    	<cfset firstName = userService.getUserById( 1 ).getFirstName()>
    <!--- catch any errors --->
    <cfcatch type="any">
    	<!--- dump the error to the browser --->
    	<cfdump var="#cfcatch#">
    	<!--- abort further processing --->
    	<cfabort>
    </cfcatch>
    </cftry>

    Expected Result: Error page: Variable USERSERVICE is undefined.

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/cfabort

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API