Obtaining a list of what exceptions code can throw
-
I'm just being lazy here but is there a way in the Visual C++ IDE (any version) to have it tell you what exceptions have been declared (by any of the methods or methods called by those methods etc...) to be possibly thrown? The only way I know of is to dig through MSDN researching each method call which can get time consuming since there are so many overloaded method variations that I tend not to assume the possible exceptions that could be thrown by one overloaded method will be the same as another overloaded method.
-
I'm just being lazy here but is there a way in the Visual C++ IDE (any version) to have it tell you what exceptions have been declared (by any of the methods or methods called by those methods etc...) to be possibly thrown? The only way I know of is to dig through MSDN researching each method call which can get time consuming since there are so many overloaded method variations that I tend not to assume the possible exceptions that could be thrown by one overloaded method will be the same as another overloaded method.
WinError.h contains all of the error codes generally thrown by WinAPI/MFC calls, but generally speaking, there's no clear way of knowing what each method will throw without looking into the documentation associated with that specific method.
-
WinError.h contains all of the error codes generally thrown by WinAPI/MFC calls, but generally speaking, there's no clear way of knowing what each method will throw without looking into the documentation associated with that specific method.
Albert Holguin wrote:
WinError.h contains all of the error codes generally thrown by WinAPI/MFC calls
I'm just trying to quickly identify which catch handlers (if any) I would need at the level in the code where I'd want to handle them. Maybe some magic hover help that would allow you to see the summary of all the "throw" declarations for the method call, definition, or declaration your cursor is currently hovering over. I apologize that I didn't word my question very good, now that I've reread it I guess it did sound like I just wanted a list of all the exceptions that could ever get thrown anywhere. :-O Regardless, thanks for taking the time to reply.
-
Albert Holguin wrote:
WinError.h contains all of the error codes generally thrown by WinAPI/MFC calls
I'm just trying to quickly identify which catch handlers (if any) I would need at the level in the code where I'd want to handle them. Maybe some magic hover help that would allow you to see the summary of all the "throw" declarations for the method call, definition, or declaration your cursor is currently hovering over. I apologize that I didn't word my question very good, now that I've reread it I guess it did sound like I just wanted a list of all the exceptions that could ever get thrown anywhere. :-O Regardless, thanks for taking the time to reply.
bob16972 wrote:
Maybe some magic hover help that would allow you to see the summary of all the "throw" declarations for the method call, definition, or declaration your cursor is currently hovering over.
Sorry, no such magic... :)
-
Albert Holguin wrote:
WinError.h contains all of the error codes generally thrown by WinAPI/MFC calls
I'm just trying to quickly identify which catch handlers (if any) I would need at the level in the code where I'd want to handle them. Maybe some magic hover help that would allow you to see the summary of all the "throw" declarations for the method call, definition, or declaration your cursor is currently hovering over. I apologize that I didn't word my question very good, now that I've reread it I guess it did sound like I just wanted a list of all the exceptions that could ever get thrown anywhere. :-O Regardless, thanks for taking the time to reply.
A basic rule of exception handling is also that you only handle exceptions that you are aware and knowledgeable of. You shouldn't just catch any and all exceptions, except for maybe at the top level of your code. So, you need to look into the documentation to see what exceptions are thrown and how to handle them anyway. It'd still be nice indeed to see what exceptions could be thrown so you can quickly check what you'd have to handle, but I'm guessing the documentation is quick enough for it anyhow, since you'll need to refer to it anyway to understand how to respond to the exception.