Recursion in a try catch?

If an exception is throw in a recursion, will the try in the recursion call catch it or will the try in the original function ran catch it? This is all assuming that the exception matches the catch block. Also in the second run the try catch is not executed.
Your question isn't clear, both because the terms you use are ambiguous and because your issue is not illustrated.

You might clarify with code, but you should know that recursive calls are no different than other function calls in C++ so the way try/catch is processed in recursive calls is no different than it is outside of them.
Essentially I am asking if inside the recursive call of the original function if a throw will be caught by the original catch or the recursive try block in the recursive function is never actually ran.


doSomething(original parameters)
{

// random code here


if ( )

{ try{ doSomething(new parameters) catch (...){ throw}


else if ( )


else if ()


throw

etc.


say the first call goes to the try block so it the same function is called but new different parameters. Then say the second run it never runs into the try block, but throws somewhere else. Will the throw in the recursive call be caught by the original catch block or will it go to the try block in the recursive call?
If a throw occurs outside of a try block, it will be caught in a function further up the call chain. In this example, it may be caught and thrown many times as the stack is unwound.
Topic archived. No new replies allowed.