Created
April 19, 2024 09:26
-
-
Save trycf/7affdff73600a10eb671c0a6cffb8011 to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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