Archive for August, 2004

Exception Handling – Too Much ‘Faith’

A recent post by Lamont Harrington asks about the proper methods for exception handling:

“Should exceptions be bubbled up the call stack and be unwound by a “global“ exception handling layer and logged appropriately, or should some form of exception handling happen at the point of code execution? “

I think a proper design does both. There are cases where the exception can be handled in the procedure where it occurs. Good defensive coding trys to identify as many of those cases as possible and handle them (Actually, good requirements and design should identify many of these situations). Obviously, you cannot foresee all circumstances so the “global” handling is necessary as well. Personally, I don’t like to repeatedly re-throw an exception up the call stack because the procedures don’t handle it specifically, I would rather let it bubble up on its own and handle it at the end. Re-throwing tends to bury the real source of the error when you are trying to debug a problem in a multi-tier application.

I have to add a plug for the Exception Managment application block. It has been very good to me so far.

Posted on:
Posted in Programming | Comments Off on Exception Handling – Too Much ‘Faith’