TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  ERR#017Checked automatically with code checker

Synopsis:A catch-all clause must do a rethrow
Language:C++
Severity Level:3
Category:Error Handling


Description:
If a catch clause catches all possible exceptions without rethrowing, all exceptions are lost.
void f()
{
   try
   {
      // Do something
   }
   catch (...)            // catch any exception
   {
      // Cleanup

      throw;              // Always rethrow the exception if catched all
   }
}

Only the "main" function of a thread must catch and report all exceptions without rethrowing.



Literature References:
Stroustrup 14.3.1 and 14.11