print information about unknown exceptions
Hello,
is it possible to get some information about an unknown (or unexpected) exception?
e.g
try{
//...do something
}
catch(...)
{
//print some information
}
in this case I want to know which exception was thrown..in other languages (java, c#...) this is possible. But I'm not sure if it is also possible in c++
Best regards
Hansjörg
Re: print information about unknown exceptions
If you use ... it's not possible. You are ignoring the exception type and then want to know what exeption? ;)
Re: print information about unknown exceptions
There's no given base interface/class/pattern that exceptions must follow, so nope. Usually exceptions are derived from std::exception though, so you could do something such as:
Code:
try
{
// ...
}
catch (std::exception& e)
{
// Log exception with information provided from e.what()
}
catch (...)
{
// Log exception with a message such as "unknown exception"
}
Re: print information about unknown exceptions
There are some libraries, example Roguewave - where the base exception class is not std::exception but one of their own, so if you are using different libraries - make sure you don't miss their base catches.
Re: print information about unknown exceptions