cffinally
Description
Executes code when a cftry or try block completes, regardless of whether
their execution throws an exception.

Category
Data output tags, Exception handling tags

Syntax
<cffinally>
   "CFML code here"
</cffinally>
See also
cftry

History
This tag is new in ColdFusion MX.

Usage
A developer might use this tag in a banking or e-commerce application, to
write an audit record after a transaction. Use it to write activity logs and
evaluate exception results.

If a page has a cfabort tag within a try block, the cffinally block is
executed after the the cfabort tag.

If anything within in a cffinally block throws an exception, execution of
the cffinally block is terminated. This exception cannot be handled by the
cftry block that is paired with the cffinally block; it can be handled by an
enclosing cftry block.

Example
This following example tests for the presence of a URL variable and records
page hits:

<!--- tests for the presence of URL variable --->
<cftry>
   IsDefined("URL.variable")
<!--- catches any exception and displays message --->
   <cfcatch>
      Go back and try again.
   </cfcatch>
<!--- increments page count using custom tag --->
   <cffinally>
       <cf_countPage>
   </cffinally>
</cftry>
You can use the cffinally tag in a cftry statement without using cfcatch.
The following example tests for the presence of a variable (it does not
throw an exception), and calls a custom tag:

<cftry>
   IsDefined("URL.variable")
      <cffinally>
          <cf_countPage>
      </cffinally>
</cftry>
This example shows the cffinally tag within a cfcatch block:

<cftry>
    <!---  business logic here --->
    <cfcatch>
    </cfcatch>
    <cffinally>
       <!--- logging here --->
    </cffinally>
</cftry>


______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to