In C++, we can get the exception information through catch(bad_cast& ex)
, then output the content of ex.what()
try{
//…
}catch(std::bad_alloc& e)
{
cout << “Catch bad alloc exception ” << e.what() << endl;
}
catch(std::bad_cast& e)
{
cout << “Catch bad alloc exception ” << e.what() << endl;
}
catch(std::bad_exception& e)
{
cout << “Catch bad alloc exception ” << e.what() << endl;
}
// catch more exception types here
// …
catch(...)
{
// how to get the content of unknown exception?
}
How to get the exception information from catch(...)
?