I'm trying to print the type name with exceptions, but my program does not even seem to catch the exception and instead seems to call the default termination function. What did I miss?
#include <cstdio> #include <exception> #include <typeinfo> namespace Error { template<typename T> class Blah : std::exception { virtual const char* what() const throw() { return typeid(T).name(); } }; } void blah() { throw Error::Blah<int*********>(); } int main() { try { blah(); } catch (std::exception& e) { std::puts(e.what()); } }
source share