> hi, i am new to building applications and would like to get > some advice on handling errors. > > I am wondering whether it is good practise to either place > error handlers such as try, cathes, where i think there may > be possible errors, such as getting files that may not be > available etc... or whether it is good practise to place > error handlers all over the code just in case unexpected errors occur > > i am quite good at identifying where the errors may be and do > as much as i can in my code to prevent errors from occuring. > > it is mainly the standard error handlers that i am not sure > what the best practise is, as i said the try catches etc..
First, use the site-wide error handler. This catches any unhandled exceptions across your entire server. It should be your last line of defense against displaying raw error messages to the user. Second, within your application, use CFERROR or the onError event, within Application.cfm or Application.cfc respectively. This allows you to include a standard error handling response for your entire application, although you won't be able to do much about errors at this level other than put a happy face on them and ensure that they're logged properly. Finally, within your application codebase itself, use CFTRY and CFCATCH when you have specific expectations of failure, and when you have something you can do about that failure. If both of those aren't true, you might as well rely on your application error handler. If you're writing components, they should generate component-specific errors, so within a component you might catch a generic error and rethrow it using CFTHROW. If you're calling components, your code should catch those component-specific exceptions and do something about them if possible. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore and Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254991 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

