Throw catch exception

Oct 18, 2016 at 1:37am
I need to understand how catch and throws work


callThePhone(parameters)
{


//do stuff

if blah blah

try{ callThePhones(parameters) } catch(...) { throw exception)


if else

else { throw exception errorthis }

// more exceptions and code

}

Correct me if I am wrong. If the function goes to the try block it will run the function and if there are any exception throw inside it will go back to the catch. If it throws inside the catch goes it go back to the try or will it unwind until the most previous try catch block besides this one?
Oct 18, 2016 at 5:18am
Does the example in the tutorial answer your question?
http://www.cplusplus.com/doc/tutorial/exceptions/
Oct 18, 2016 at 11:07am
No. I was asking if the throw inside the catch gets rethrown back to the try block above it or does it exit to the other previous try catch block.
Oct 18, 2016 at 11:14am
Throwing in the catch block does not differ from any other throw. That means it will be catched by an encompassing try/catch if any. No try preceding this catch will be involved.
Topic archived. No new replies allowed.