The idea is "try you()
, if it fails try _do()
, if it fails report the exception from the first try, i.e., you()
".
void that_thing() {
try {
you();
} catch( ... ) {
bool error=false;
try {
_do();
} catch( ... ) {
error = true;
}
if( error ) throw;
}
}
Testing with Gcc it worked fine, I was wondering if it will work with any compiler. Just to be clearer, the weird behavior I was expecting was that the throw;
would rethrow the inner exception.
Edit: This question is NOT about the inner most catch
, it is about rethrowing the outer exception after catching the inner most. The question is if this kind of rethrowing is legally definitely was not approached on the question that are being pointed as similar.