Skip to main content
This topic has been closed for replies.

1 reply

Known Participant
September 12, 2012

Does the block still executes if there is a CFRETHROW or another exception happens in the CFCATCH block?

Inspiring
September 12, 2012

Did you try it? What happened?

--

Adam

Known Participant
September 12, 2012

Yes, I just did. CFFINALLY executes after CFTHROW even with a CFTHROW/RETHROW in the catch block.

Sample Code:

<CFTRY>

          <CFTRY>

                    <CFSET TESTVAR="Tried">

                    <CFTHROW TYPE="EX_SECFAILED" ErrorCode="XXX">

                    <CFCATCH>

                              <CFSET TESTVAR="Rethrown-1">

                              <CFRETHROW>

                              <CFSET TESTVAR="Rethrown-2">

                    </CFCATCH>

                    <CFFINALLY>

                              <CFSET TESTVAR="Finallied">

                    </CFFINALLY>

          </CFTRY>

          <CFOUTPUT><h3>No Error:#TESTVAR#</h3></CFOUTPUT>

<CFCATCH>

          <CFOUTPUT><h3>Error:#TESTVAR#</h3></CFOUTPUT>

</CFCATCH>

</CFTRY>

1) When run, the output is: Error:Finallied

2) When the CFFINALLY block is commented out, output is: Error:Rethrown-1

3) When the CFFINALLY block is not commented out and CFTHROW is commented, output is: No Error:Finallied