can I get description of an exception caught by
catch(...)
block? something like .what() of std::exception.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is one trick you might be able to use:
and so on, for as many different types as you think might be thrown. If you really know nothing about what might be thrown then even that second-to-last one is wrong, because somebody might throw a
char*that doesn’t point to a nul-terminated string.It’s generally a bad idea to throw anything that isn’t a
std::exceptionor derived class. The reasonstd::exceptionexists is to allow everybody to throw and catch objects that they can do something useful with. In a toy program where you just want to get out of there and can’t even be bothered to include a standard header, OK, maybe throw anintor a string literal. I don’t think I’d make that part of a formal interface. Any exceptions you throw are part of your formal interface, even if you somehow forgot to document them.