Defining Structured Exceptions (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):
|31-30|| 11 = error (normal)|
00 = success
01 = informational
10 = warning
|29||1 = 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.