Exceptions : Combining C++ and Structured Exception Handling ? 
Author Message
 Exceptions : Combining C++ and Structured Exception Handling ?

Hi All,

To my knowledge :

Structured Exception Handling (SEH) provides a means to deal with
problems such as memory access violations, divide by zero and
so forth.

The C++ CException and derived classes provide a means to
handle memory allocation errors and the like - but not the more
low level errors captured by the SEH system.

My problem !

Microsoft say that in MFC applications you are best to use the
C++ methods (ie. try, throw, catch). The old macro method is
to be avoided at all costs. In discussing the SEH system they
(the documentation) says it is robust but as it is not C++ specific
the c++ method (try, etc) is preferred.

Now I have an application, in which I would like to trap low level
errors, such as divide by zero, memory access and would also
like to trap my own exceptions, which will be derived from CException.

(This is form of handling is needed because I am writing container
code which is intended to test other code - the other code may
not be well written and the container code needs to be capable
of trapping errors and continuing).

I have not been able to handle memory access violations through the
c++ exception system, the only way I have found to handle these
is to use the SEH system of __try and __except.

I have also found that the compiler will not let you use the two forms
of exception handling (SEH and c++) in the same function.

The question !

What is the preferred way (or how do I) handle exceptions generated
from my own throws and also those generated through SEH (ie. Memory
access violations).

Thanks for your time,

Gareth

My attempts at using c++ exceptions to catch a memory access violation
- just so we're talking about the same thing

 try {
  int *p = 0;
  *p = 13;
 }
 catch (exception except) {
  TRACE0("woah\n");
 }

 catch (CException except) {
  TRACE0("Error\n");
 }

 catch (unsigned int except) {
  TRACE0("Hello\n");
 }



Sun, 13 Aug 2000 03:00:00 GMT  
 Exceptions : Combining C++ and Structured Exception Handling ?

On Wed, 25 Feb 1998 19:27:43 -0000, "Gareth Thorburn"

Quote:

>What is the preferred way (or how do I) handle exceptions generated
>from my own throws and also those generated through SEH (ie. Memory
>access violations).

You can convert SEs into C++ exceptions with the help of
_set_se_translator.

--
Doug Harrison



Sun, 13 Aug 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Crash In Exception Filter in Structured Exception HAndling

2. Floating Point Exceptions: MFC or Structured Exception Handling?

3. Win32 structured exceptions vs C++ exceptions

4. Exception handling - how to know which exceptions are thrown

5. using Structured Exception Handling with ATL..??

6. ways to deal with Structured Exception Handling

7. Win32 Structured Exception Handling and Object unwinding

8. Structured Exception Handling

9. structured exception handling on the ARM (iPAQ)

10. Nesting structured exception handling ?

11. Translate a SEH exception into a C++ exception

12. Catching hardware exceptions using C++ exceptions

 

 
Powered by phpBB® Forum Software