I think it depends on the circumstances. For all "heavy hitting" (queries,
ftp, pop, file manipulation, etc) I use try/catch. In the simple case of
checking for a variable I think it is overkill to use try/catch when a
simple cfif can fix the prob for you. I wouldn't use the block you have but
a 1 line cfif with a cfelse would suffice my typical situations.
<cfif isDefined("ID") AND NOT isNumeric("ID")>
handle it
<cfelse>
set ID
</cfif>
On 2/15/06, Michael Dinowitz <[EMAIL PROTECTED]> wrote:
>
> This is a question of best practices and why. When I know there's a chance
> of a specific error, I tend to code specifically to handle it. Others code
> generally using try/catch. Which is seen as best in other languages and why?
> I doubt there's any real performance issue between them, so it's a question
> of industry standard and style.
>
> For example, if I know an ID is needed on a page and it has to be a
> numeric I'd do:
> <CFIF Not IsDefined('ID')>
> An ID is needed
> <CFELSEIF Not IsNumeric(ID)>
> The passed ID needs to be numeric
> </CFIF>
>
> Others do:
> <CFTRY>
> <cfparam name="ID" type="numeric">
> <CFCATCH>
> You must pass a numeric ID
> </CFCATCH>
> </CFTRY>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232332
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54