Thursday, August 31, 2006

Exception Rules

Scott Hanselman is working on some rules of thumb for managing exceptions in .NET, but some of these concepts will translate to other languages. The most important to me are:

  • Exceptions should be exceptional.
  • Don't catch exceptions you can't do anything about.
  • Avoid swallowing exceptions, but if you have to swallow an exception, make sure it is well documented, and log it when it happens if possible. Evidently some code out there has performance problems because a large number of exceptions are routinely raised and silently swallowed.

No comments: