Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Obtaining a list of what exceptions code can throw

Obtaining a list of what exceptions code can throw

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studioquestionannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bob16972
    wrote on last edited by
    #1

    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.

    A 1 Reply Last reply
    0
    • B bob16972

      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.

      A Offline
      A Offline
      Albert Holguin
      wrote on last edited by
      #2

      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.

      B 1 Reply Last reply
      0
      • A Albert Holguin

        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.

        B Offline
        B Offline
        bob16972
        wrote on last edited by
        #3

        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 M 2 Replies Last reply
        0
        • B bob16972

          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 Offline
          A Offline
          Albert Holguin
          wrote on last edited by
          #4

          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... :)

          1 Reply Last reply
          0
          • B bob16972

            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.

            M Offline
            M Offline
            MicroVirus
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups