Which types of exception not to catch?

The usual advice applies, only catch what you can handle. There’s a utility function named IsCriticalException inside the framework that’s pretty commonly used by parts of the framework code to decide whether or not to swallow an exception. Might as well go by that. It considers the following critical:

  • NullReferenceException
  • StackOverflowException (uncatchable)
  • OutOfMemoryException
  • ThreadAbortException
  • ExecutionEngineException (uncatchable in 4.0)
  • IndexOutOfRangeException
  • AccessViolationException

It is a good list.

Leave a Comment