I have the following structure in the legacy codebase:
try{
...
}
catch(Type1&){
...
}
catch(Type2&){
...
}
...
And with copy-paste development, the same catch blocks show up everywhere. Now, I would write a function like this:
void catchErrors(){
try{
throw;
}
catch(Type1&){
...
}
...
}
and put it into the code like this:
try{
...
}
catch(...){
catchErrors();
}
Will this be a valid refactor, resulting in the same functionality?
(And do you have any better suggestion for the refactor?)