简体   繁体   中英

How can I handle exception in catch block in c++

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.

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM