我可以在catch(...)块中获取异常对象的类型名称吗?
#define EXIT_THROUGH_EXCEPTION 1
#define EXIT_THROUGH_UNKNOWN_EXCEPTION 2
void error_info(ostream& stream, const string& msg, unsigned int line);
int main()
try{
// Here is main code...
}
catch (exception& ex){ // Any exception based on the std::exception class
error_info(cerr, ex.what(), __LINE__);
return EXIT_THROUGH_EXCEPTION;
}
catch (...){ // other exception type
// TODO: what is instead of "???"?
error_info(cerr, "Unknown exception: " + typeid("???").name, __LINE__);
return EXIT_THROUGH_UNKNOWN_EXCEPTION;
}