-1

say I have code

try
{
   .... 
}
catch()
{
   .... // exception occur here ... how to handled. 
}

Is there any mechanism in c++ by which the above scenario can be handled.

Nihar
  • 347
  • 2
  • 16

1 Answers1

2

If you think this is what you really want, you can do it like this:

try
{
    try
    {
        //...
    }
    catch( ... )
    {
        //...
        if( .. )
            throw std::runtime_exception( "error occured" );
    }
}
catch( std::runtime_exception& e )
{
    // handle exception of exception handler
}
Raoul Steffen
  • 527
  • 4
  • 10
  • I am also thinking of same but ... dont know whether this is the best way to anything else can also be done ... ? – Nihar Nov 18 '14 at 08:48
  • @Nihar: You could also put a try-catch block into the `catch( ... )`-body: `try{ } catch( ... ){ try{ } catch( ... ) }` – Raoul Steffen Nov 18 '14 at 12:52