At the top of my program, I have an exception handler.
It looks something like this:
try{
//majority of program
}
catch(...){
Handle_All_Exceptions();
}
void Handle_All_Exceptions(){
try{throw;}
catch(TypeA const& e){Handle(e) ;}
catch(TypeB const& e){Handle(e) ;}
catch(TypeC const& e){Handle(e) ;}
catch(TypeD const& e){Handle(e) ;}
catch(...) {Handle_Unknown();}
}
void Handle(TypeA const& e){
//...
}
void Handle(TypeB const& e){
//...
}
void Handle(TypeC const& e){
//...
}
void Handle(TypeD const& e){
//...
}
void Handle_Unknown(){
//...
}
As I obtain more an more exception types,
I'd like to take a more generic approach.
How can I apply generic programming to the Handle_All_Exceptions
function?
Would something like this be possible in newer versions of C++?
catch(auto e){Handle(e)};
catch(...){Handle_Unknown();}