On Tuesday, Oct 15, 2002, at 07:51 US/Pacific, S. Isaac Dealey wrote:
> I suppose I should clarify by saying that I haven't simply disregarded 
> the
> original intent of <cftry> all-together. I do use it mostly for error
> handling, although much of it is for custom error handling, such as 
> server
> side form validation.

Although I would maintain that you would 'expect' user input to contain 
errors (and therefore this is not an 'ideal' use of try/catch), I would 
also concede that try/catch can make this sort of validation easier and 
interacting with a user for error handling is much less performance 
critical.

> There have been a handful ( maybe a half dozen ) situations where I 
> found
> the <cftry> was extremely helpful in creating an easily human 
> read/writeable
> codeblock where the only alternative I could think of would have been a
> horrible mess of spaghetti code.

Yes, that is true. There are extenuating circumstances for most abuses 
of a language :)

I'm sure you wouldn't even consider doing this:

<cffunction name="factorial" returntype="numeric">
        <cfargument name="n" type="numeric" required="true"/>
        <cfif n le 1>
                <cfthrow type="result" message="1"/>
        <cfelse>
                <cftry>
                        <cfset factorial(n-1)/>
                <cfcatch type="result">
                        <cfset nfact = n * #cfcatch.message#/>
                        <cfthrow type="result" message="#nfact#"/>
                </cfcatch>
                </cftry>
        </cfif>
</cffunction>

<cfparam name="url.n" type="numeric" default="5"/>

<cftry>
        <cfset factorial(url.n)/>
<cfcatch type="result">
        <cfoutput>
                factorial #url.n# is #cfcatch.message#
        </cfoutput>
</cfcatch>
</cftry>

"I can smell your brains!"
-- Mittens the Kitten : http://www.matazone.co.uk/theotherside.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to