Betty Mock
Betty Mock

Reputation: 1393

Does cfcatch stop the processing?

I have a ColdFusion query and am looping over the output. I need a try/catch because there could be cases where the output of the query doesn't quite match the information I am processing. It SHOULD match, but I am antsy about counting on it. However, if there is a mismatch, no harm is done. I just want to skip that transaction and go on. What I don't want is for ColdFusion to throw an error, stop the process, and upset my users.

In code like that below, will the loop continue processing if it falls into the "catch" clause? There doesn't seem to be anything in the documentation I found which addresses this question.

<cfoutput query = "xyz">
<cftry>
   do something with this line of query output ...
   <cfcatch type = "any">
   no action, just continue with the loop ...
   </cfcatch>
</cftry>
</cfoutput>

Upvotes: 4

Views: 1398

Answers (1)

Brad Wood
Brad Wood

Reputation: 3953

An empty catch block will silently ignore the error and continue processing. You should probably at least log the error though so you know if something is failing.

All that said, there are probably better ways to detect problems with the code than to try/catch it. I don't understand what you mean when you say "the query [might not] quite match the information I am processing" so I can't provide any more specific of an example.

Upvotes: 4

Related Questions