Defining Structured Exceptions (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Structured Exceptions Under Win32 (C++)

Raising a Win32 exception that is handled within the same program does not generally make much sense: C++ exceptions can do the job better, remain significantly more portable, and use a simpler syntax. Win32 exceptions do have the advantage, however, that they can be handled by components that may not have been compiled with the same C++ compiler.

The first step is to define the exception. An exception is a 32-bit integer with the following format (starting at bit 0):

Bit Meaning
31-30 11 = error (normal)
00 = success
01 = informational
10 = warning
29 1 = user-defined
28 Reserved
27-0 User-defined

In addition to defining the exception code, you need to decide whether or not to include additional information with the exception (accessible to the filter/handler from the exception record). There is no conventional method for encoding additional parameters in the exception code.

See Also