try, throw and catch statement
-
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 usereturn
inside acatch
statement? Is that permitted? Thanks in advance... Hello World!!! :) from Raphaël -
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 usereturn
inside acatch
statement? Is that permitted? Thanks in advance... Hello World!!! :) from RaphaëlIf 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
-
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
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
-
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
You
throw
by value, and you catch byconst 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.