Example #1
0
void
DoSomething2()
{
  cout << "in DoSomething2 - before try block" << endl;

  EH_REGISTER(EH_ALL_EXCEPTIONS);                       // <---
  EH_REGISTER(EH_OUT_OF_RANGE);                         // <---
  EH_TRY                                                // <--- try block
  {
    cout << "in DoSomething2 - in try block before calling DoMore" << endl;
    DoMore();
  }
  EH_END_TRY                                            // <--- xxxxx
  EH_CATCH(EH_OUT_OF_RANGE)                             // <--- catch block
  {
    cout << "in DoSomething2 - in Out of Range catch block" << endl
         << "                 before throw Out of Range statement" << endl
         << "in DoSomething2 - line " << __LINE__ << " : "
         << " *** Error *** This line is not supposed to be printed" << endl;
    EH_THROW(EH_OUT_OF_RANGE);                          // <--- throw
  }
  EH_CATCH(EH_ALL_EXCEPTIONS)                           // <--- catch block
  {
    cout << "in DoSomething2 - in All Exceptions (...) catch block" << endl
         << "                  EH_ARITHMETIC_OVERFLOW caught" << endl
         << "in DoSomething2 - before throw Arithmetic Overflow statement"
         << endl;

    EH_THROW(EH_ARITHMETIC_OVERFLOW);
  }

  cout << "in DoSomething2 - line " << __LINE__ << " : "
       << " *** Error *** This line is not supposed to be printed" << endl;
}
Example #2
0
void
DoSomething ()
{
  cout << "in DoSomething - before try block" << endl;

  DoMore();

  cout << "file " << __FILE__ << " - line " << __LINE__ << " : "
    << "This line is not supposed to be printed" << endl;
}
Example #3
0
void
DoSomething ()
{
  cout << "in DoSomething - before try block" << endl;

  EH_REGISTER(EH_OUT_OF_RANGE);                         // <---
  EH_TRY                                                // <--- try block
  {
    cout << "in DoSomething - in try block before calling DoMore" << endl;
    DoMore();
  }
  EH_END_TRY                                            // <---
  EH_CATCH(EH_OUT_OF_RANGE)                             // <--- catch block
  {
    cout << "in DoSomething - in Out of Range catch block" << endl
         << "                 before throw Out of Range statement" << endl;
    EH_THROW(EH_OUT_OF_RANGE);                          // <--- throw
  }

  cout << "file " << __FILE__ << " - line " << __LINE__ << " : "
       << " *** Error *** This line is not supposed to be printed" << endl;
}