GetExceptionCode
GetExceptionCode retrieves a code that identifies the type of exception that occurred. The function can be called only from within the filter expression or exception-handler block of a try-except exception handler.
Syntax
DWORD GetExceptionCode(VOID);
Parameters
This function has no parameters.
The type of exception
The following list shows the exception codes that are likely to occur due to common programming errors. For more information, see RTX Exception Handling.
- EXCEPTION_ACCESS_VIOLATION — The thread attempted to read from or write to a virtual address for which it does not have the appropriate access.
- EXCEPTION_BREAKPOINT — A breakpoint was encountered.
- EXCEPTION_DATATYPE_MISALIGNMENT — The thread attempted to read or write data that is misaligned on hardware that does not provide alignment. For example, 16-bit values must be aligned on 2-byte boundaries, 32-bit values on 4-byte boundaries, and so on.
- EXCEPTION_FLT_DENORMAL_OPERAND — One of the operands in a floating-point operation is denormal. A denormal value is one that is too small to represent as a standard floating-point value. The thread attempted to divide a floating-point value by a floating-point
- EXCEPTION_FLT_DIVIDE_BY_ZERO — The thread attempted to divide a floating-point value by a floating-point divisor of zero.
- EXCEPTION_FLT_INEXACT_RESULT — The result of a floating-point operation cannot be represented exactly as a decimal fraction.
- EXCEPTION_FLT_INVALID_OPERATION — This exception represents any floating-point exception not included in this list.
Remarks
GetExceptionCode can be called only from within the filter expression or exception-handler block of a try-except statement. The filter expression is evaluated if an exception occurs during execution of the try block, and it determines whether the except block is executed. The following example shows the structure of a try-except statement.
try { /* try block */ } except (filter-expression) { /* exception handler block */ }
The filter expression can invoke a filter function. The filter function cannot call GetExceptionCode. However, the return value of GetExceptionCode can be passed as a parameter to a filter function. The return value of the GetExceptionInformation function can also be passed as a parameter to a filter function. GetExceptionInformation returns a pointer to a structure that includes the exception-code information. In the case of nested try-except statements, each statement's filter expression is evaluated until one is evaluated as EXCEPTION_EXECUTE_HANDLER or EXCEPTION_CONTINUE_EXECUTION. Each filter expression can invoke GetExceptionCode to get the exception code. The exception code returned is the code generated by a hardware exception, or the code specified in the RaiseException function for a software-generated exception.
See Also: