Click to See Complete Forum and Search --> : print information about unknown exceptions


hansipet
June 6th, 2007, 01:51 AM
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

cilu
June 6th, 2007, 04:31 AM
If you use ... it's not possible. You are ignoring the exception type and then want to know what exeption? ;)

reko_t
June 6th, 2007, 05:49 AM
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:
try
{
// ...
}
catch (std::exception& e)
{
// Log exception with information provided from e.what()
}
catch (...)
{
// Log exception with a message such as "unknown exception"
}

exterminator
June 6th, 2007, 07:14 AM
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.

hansipet
June 6th, 2007, 08:22 AM
thanks..bad news...