Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trycf/7affdff73600a10eb671c0a6cffb8011 to your computer and use it in GitHub Desktop.
Save trycf/7affdff73600a10eb671c0a6cffb8011 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfset myArray = ['anError', 'noError'] >
<cfoutput><h1>Original version</h1></cfoutput>
<!-- throw errors -->
<cfloop array="#myArray#" item='doError'>
<cftry>
<cfoutput>
<br />
#doError#
</cfoutput>
<cfif doError EQ 'anError'>
<cfoutput>!there's an error!</cfoutput>
<cfthrow />
</cfif>
<cfoutput>!Everything is FINE!</cfoutput>
<cfcatch>
<cfoutput></cfoutput>
</cfcatch>
</cftry>
</cfloop>
<cfoutput><h1>Version without throwing an error</h1></cfoutput>
<!-- without throwing -->
<cfloop array="#myArray#" item='doError'>
<cftry>
<cfoutput>
<br />
#doError#
</cfoutput>
<cfif doError EQ 'anError'>
<cfoutput>!there's an error!</cfoutput>
</cfif>
<cfoutput>!Everything is FINE!</cfoutput>
<cfcatch>
<cfoutput></cfoutput>
</cfcatch>
</cftry>
</cfloop>
<cfoutput><h1>My fixed version without throwing an error</h1></cfoutput>
<!-- without throwing -->
<cfloop array="#myArray#" item='doError'>
<cftry>
<cfoutput>
<br />
#doError#
</cfoutput>
<cfif doError EQ 'anError'>
<cfoutput>!there's an error!</cfoutput>
<cfelse>
<cfoutput>!Everything is FINE!</cfoutput>
</cfif>
<cfcatch>
<cfoutput></cfoutput>
</cfcatch>
</cftry>
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment