Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

It is important that resources are reclaimed when exceptions are thrown. Throwing an exception may result in cleanup code being bypassed. As a result, it is the responsibility of the exception handler to properly cleanup. This may be problematic if the exception is to be caught in a different function or module. Instead, it is preferable if resources are reclaimed automatically when objects go out of scope.

Non-

...

Compliant Code Example

Code Block
while (moreToDo) {
   SomeType *pst = getNextItem();
   try {
      pst->processItem();
   }
   catch (...) {
      // deal with exception
      throw;
   }
   delete pst;
}

...