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. try, throw and catch statement

try, throw and catch statement

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 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.
  • R Offline
    R Offline
    Raphael Kindt
    wrote on last edited by
    #1

    Hi world... OS = Win2K with VC++6.0 I have some problem but I don't know who causes this problem (I suppose that's the use of exception)...!!! :confused: The problem is that I catch a BSOD! X| How the use of exception can gives me a BSOD??? Can I throw exceptions OR use return inside a catch statement? Is that permitted? Thanks in advance... Hello World!!! :) from Raphaël

    G 1 Reply Last reply
    0
    • R Raphael Kindt

      Hi world... OS = Win2K with VC++6.0 I have some problem but I don't know who causes this problem (I suppose that's the use of exception)...!!! :confused: The problem is that I catch a BSOD! X| How the use of exception can gives me a BSOD??? Can I throw exceptions OR use return inside a catch statement? Is that permitted? Thanks in advance... Hello World!!! :) from Raphaël

      G Offline
      G Offline
      G Steudtel
      wrote on last edited by
      #2

      If you can I don't know, but you may (at least this month). If you return you should delete the exception, usually by calling e->Delete(). You may also throw this same exception again, or throw another one. In this case you also should Delete() the old exception. If you throw the same exception it won't be caught by this code, because it is thrown outside the try block. In this case it acts like it is passed through. G. Steudtel

      R 1 Reply Last reply
      0
      • G G Steudtel

        If you can I don't know, but you may (at least this month). If you return you should delete the exception, usually by calling e->Delete(). You may also throw this same exception again, or throw another one. In this case you also should Delete() the old exception. If you throw the same exception it won't be caught by this code, because it is thrown outside the try block. In this case it acts like it is passed through. G. Steudtel

        R Offline
        R Offline
        Raphael Kindt
        wrote on last edited by
        #3

        G. Steudtel wrote: If you can I don't know, but you may (at least this month). Oops... Sorry... But I'm not an English expert...:-O I don't use CException of MFC!!! I use exception class from the C++ standard library. Thus, How to reproduce the delete method of MFC? Re-thanks... Hello World!!! :) from Raphaël

        J 1 Reply Last reply
        0
        • R Raphael Kindt

          G. Steudtel wrote: If you can I don't know, but you may (at least this month). Oops... Sorry... But I'm not an English expert...:-O I don't use CException of MFC!!! I use exception class from the C++ standard library. Thus, How to reproduce the delete method of MFC? Re-thanks... Hello World!!! :) from Raphaël

          J Offline
          J Offline
          jhwurmbach
          wrote on last edited by
          #4

          You throw by value, and you catch by const reference. No need to delete, you make these Exceptions on the stack, and if you re-throw it will get copied. This way you can catch a derived exception as its base (say std::exception), re throw the std::exception object and catch again as a derived exception. And NEVER EVER touch MFC exceptions.... I have a small hierarchy of exception classes, eventually derived from std::exeption, and their c'tors are filling the error-string with a sensible message, and then add filename and line number of the error to member strings, so I can have a look when debugging.


          My opinions may have changed, but not the fact that I am right.

          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