I have a function foo
that can throw a bar
exception.
In another function I call foo
but I have the ability to add some more detail to the bar
exception if thrown. (I'd rather not pass such information as a parameter to foo
as it doesn't really belong there due to the generic nature of that function.)
So I do this in the caller:
try {
foo();
} catch (bar& ex){
ex.addSomeMoreInformation(...);
throw;
}
Will throw
re-throw the modified exception or do I need to use throw ex;
? The latter would presumably take a value copy so I'd rather not do that. Would throw
take a value copy too? I suspect it wouldn't.
(I'm aware I could verify but I'm concerned about stumbling on an unspecified or undefined construct so would like to know for sure).