I generally try to avoid try/catch except if
a) there's no other good way to trap for the error
b) it's a seldom-used utility function and it doesn't pay to write it better
So, yeah. I'm with you in this one.
--Ben
Michael Dinowitz 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:232338
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