I currently have some code I am trying to refactor. A large set of exceptions has some common code for all exceptions as well as some specific code which needs to be handled
I would really just move the common code to a function.
Here is another idea:
try {
/* Stuff that may fail */
} catch( const std::exception & e) {
/* do common part here */
if (const exception1 * e1 = dynamic_cast(&e) {
/* do stuff for exception1 here */
} else if (const exception2 * e2 = dynamic_cast(&e) {
/* do stuff for exception2 here */
} else
throw;
}