Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C++ what happens if an exception occurs inside catch block?

What happens if an exception occurs inside a catch block?

try {}
catch(...)
{
    stream.close(); // IO exception here
}

What’s the default behaviour?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Nothing special will happen. A new exception object will be initialized by the throw expression inside the call and a search for a matching catch handler will start, which on escaping the function call will continue on the nearest enclosing try block (enclosing the shown try/catch pair). The old exception object will be destroyed during stack unwinding when leaving the old handler, since it wasn’t rethrown.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading