Ok, I'm reworking an application to utilize CFC's.  I've got a pretty
standard add/edit/delete/display data function I'm retooling into a cfc.  My
question is that my original inline procedural code (see below) had error
handling wrapped around the <CFC> database connections.  Allowing me to more
gracefully handle problems with the adding of a new record.

My question is, "What are best practices" for doing this inside a CFC?  How
would one capture and display errors inside a function?  Especially if one
is trying to separate business logic and display logic?

Thanks.

--------------
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA
 
*******************
*** Code sample ***
*******************

<cftransaction action="begin">
        <cfset Success = true>
        <cftry>
                <cfquery datasource="CPS">
                        <<< INSERT SQL HERE >>>
                </cfquery>
        <cfcatch>
                <cfset Success = false>
                <cfdump var="#cfcatch#" expand="no">
        </cfcatch>
        </cftry>
<cfif Success>
        <cftransaction action="commit"/>
        <cflocation <<<return to calling page>>>>
<cfelse>
        <cftransaction action="rollback"/>
        <p>Database Error: Data was not recorded.</p>
</cfif>
</cftransaction>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Get the mailserver that powers this list at 
http://www.coolfusion.com

Reply via email to