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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ Exception Programming

C++ Exception Programming

Scheduled Pinned Locked Moved C / C++ / MFC
c++javajsonquestion
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.
  • P Offline
    P Offline
    pgav
    wrote on last edited by
    #1

    Hello, I'm trying to program a few exception classes for use in some software I'm working on. I'm more familliar with Java style of exception programming, and am having trouble finding some good API documentation on C++ exception classes. My plan was to inherit from exception, or runtime_error, however I can't find figure out what methods I'm inheriting without a good API. Does anone know of a good API page on the exeption classes? Thanks. Patrick

    L J 2 Replies Last reply
    0
    • P pgav

      Hello, I'm trying to program a few exception classes for use in some software I'm working on. I'm more familliar with Java style of exception programming, and am having trouble finding some good API documentation on C++ exception classes. My plan was to inherit from exception, or runtime_error, however I can't find figure out what methods I'm inheriting without a good API. Does anone know of a good API page on the exeption classes? Thanks. Patrick

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      http://www.cplusplus.com/doc/tutorial/exceptions.html[^]

      "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
      Colin Angus Mackay in the C# forum

      led mike

      P 1 Reply Last reply
      0
      • L led mike

        http://www.cplusplus.com/doc/tutorial/exceptions.html[^]

        "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
        Colin Angus Mackay in the C# forum

        led mike

        P Offline
        P Offline
        pgav
        wrote on last edited by
        #3

        Thanks for the link, that puts me on the right trak; however, considering the following example: // standard exceptions #include #include using namespace std; class myexception: public exception { virtual const char* what() const { return "My exception happened"; } } myex; int main () { try { throw myex; } catch (exception& e) { cout << e.what() << endl; } return 0; } This example does part of what I'm looking for, however I'd like to have more options when using the exception class. I'd like to give the programmer the option of passing in their own error message to the exception class, or to just use the default. Anyone know where I can look fir this? Thanks. Patrick -- modified at 16:47 Thursday 13th July, 2006

        L 1 Reply Last reply
        0
        • P pgav

          Hello, I'm trying to program a few exception classes for use in some software I'm working on. I'm more familliar with Java style of exception programming, and am having trouble finding some good API documentation on C++ exception classes. My plan was to inherit from exception, or runtime_error, however I can't find figure out what methods I'm inheriting without a good API. Does anone know of a good API page on the exeption classes? Thanks. Patrick

          J Offline
          J Offline
          Joe Woodbury
          wrote on last edited by
          #4

          With C++ exceptions, you can throw any object, even an int if you feel like it. There is no base exception class. (STL has an exception class, but it's very limited.) I STRONGLY suggest writing your own exception class and write it to fit your requirements. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          1 Reply Last reply
          0
          • P pgav

            Thanks for the link, that puts me on the right trak; however, considering the following example: // standard exceptions #include #include using namespace std; class myexception: public exception { virtual const char* what() const { return "My exception happened"; } } myex; int main () { try { throw myex; } catch (exception& e) { cout << e.what() << endl; } return 0; } This example does part of what I'm looking for, however I'd like to have more options when using the exception class. I'd like to give the programmer the option of passing in their own error message to the exception class, or to just use the default. Anyone know where I can look fir this? Thanks. Patrick -- modified at 16:47 Thursday 13th July, 2006

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            pgav wrote:

            Anyone know where I can look fir this?

            What Joe Woodbury said is correct. The C++ base exception class only defines what() so unless you want to use that you can just create your own base exception class to your own design requirements.

            "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
            Colin Angus Mackay in the C# forum

            led mike

            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