I have some program and every time I run it, it throws an exception.
I don’t know how to check what exactly it throws, so my question is: is it possible to catch exception and print it?
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.
If it derives from
std::exceptionyou can catch by reference:But if the exception is some class that has is not derived from
std::exception, you will have to know ahead of time it’s type (i.e. should you catchstd::stringorsome_library_exception_base).You can do a catch all:
but then you can’t do anything with the exception.