I have a CFC that does my error handling.
I use a try/catch block, when an error occurs, I call the CFC and this CFC
creates a dump of all the error information plus all variable scopes, and
creates a nice friendly error message, like the windows ones, with a hidden
div that contains all the error information.
The alert then contains a button to view the error, which then shows the
hidden div, so you can still view the errors from the site.
A copy of the error is also emails to the webmaster so he can track errors
on the sites.

The usualy problem with error trapping, is that a client reports an erorr on
the site, and no-one can see it, and if visitors to the site get an error,
you don't even know about it.  with the above method, it's very easy to
debug without breaking an application, and I usually get the emails with the
error before the client reports it or even knows about it.

Russ
 

-----Original Message-----
From: Michael Dinowitz [mailto:[EMAIL PROTECTED] 
Sent: 15 February 2006 15:38
To: CF-Talk
Subject: Try/Catch vs. direct error handling

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:232369
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

Reply via email to