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;
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.
In this example we demonstrate using the
<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.
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.