I am using the try/catch method to trap exceptions. How can I find out what kind of an exception I get with catch (...), and how can I get the exception's related data?
If the exception-declaration statement is an ellipsis (...), the catch clause handles any type of exception, including C exceptions as well as system-generated and application-generated exceptions. This includes exceptions such as memory protection, divide-by-zero, and floating-point violations. An ellipsis catch handler must be the last handler for its try block.
I don't think you can identify in code which exception was caught by the catch(...). You should look at the code that is being called and identify potential exceptions, then catch those separately.
You should also use the debugger if you are having a specific problem, since you can edit the exceptions options to always stop on any exception that can be caught be a catch(...).
If you have RTTI information enabled, you might(should?) be able to use va_args (for the ... expansion) and be able to determine the exceptions type and handle the ones you want.
Disclaimer: I've never attempted this, so if it works, great. If it doesn't work, well then sorry about your luck. Please let me know one way or the other, though.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.