cfretry

Used within a catch block to jump back to the beginning of the try statement.

  <cfretry>

 retry

This tag requires Lucee.  Not supported on Adobe ColdFusion, etc.

Examples
Sample code using the cfretry tag

Throw an error and retry within cfcatch until the iteration counter is equal to 3.

<cfoutput>
<cfset iterations = 1/>
<cfset limit = 3/>

<cftry>
	<cfif iterations EQ limit>
		Done!
	<cfelse>
		<cfthrow type='Custom' message='Too soon. '/>
	</cfif>

	<cfcatch>
		#cfcatch.message#

		<cfset iterations += 1/>
		<cfif iterations LE limit>
			<cfretry/>
		</cfif>
	</cfcatch>
</cftry>
</cfoutput>

Expected Result: Too soon. Too soon. Done!

Throw an error and retry within catch until the iteration counter is equal to 3.

iterations = 1;
limit = 3;

try {
	if (iterations == limit) {
		writeOutput('Done!');
	} else {
		throw(message='Too soon. ');
	}
}
catch(any e) {
	writeOutput('#cfcatch.message#');

	iterations += 1;
	if (iterations <= limit) {
		retry;
	}
}

Expected Result: Too soon. Too soon. Done!

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub