Compartilhar via


GetExceptionCode

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function retrieves a code that identifies the type of exception that occurred.

GetExceptionCode can be called only from within the filter expression or exception-handler block of a try-except exception handler.

Syntax

DWORD GetExceptionCode(void);

Parameters

None.

Return Value

The return value identifies the type of exception, as shown in the following list:

  • EXCEPTION_ACCESS_VIOLATION
    The thread attempted to read from or write to a virtual address that it does not have appropriate access to.
  • EXCEPTION_ARRAY_BOUNDS_EXCEEDED
    The thread attempted to access an array element that is out of bounds, and the underlying hardware supports bounds checking.
  • 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
    An operand in a floating-point operation is too small to represent as a standard floating-point value.
  • 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 a floating-point exception not included in this list.
  • EXCEPTION_FLT_OVERFLOW
    The exponent of a floating-point operation is greater than the magnitude allowed by the corresponding type.
  • EXCEPTION_FLT_STACK_CHECK
    The stack overflowed or underflowed as a result of a floating-point operation.
  • EXCEPTION_FLT_UNDERFLOW
    The exponent of a floating-point operation is less than the magnitude allowed by the corresponding type.
  • EXCEPTION_INT_DIVIDE_BY_ZERO
    The thread attempted to divide an integer value by an integer divisor of zero.
  • EXCEPTION_INT_OVERFLOW
    The result of an integer operation caused a carry out of the most significant bit of the result.
  • EXCEPTION_NONCONTINUABLE_EXCEPTION
    The thread attempted to continue execution after a noncontinuable exception occurred.
  • EXCEPTION_PRIV_INSTRUCTION
    The thread attempted to execute an instruction whose operation is not allowed in the current machine mode.
  • EXCEPTION_SINGLE_STEP
    A trace trap or other single-instruction mechanism signaled that one instruction has been run.

Remarks

The Excpt.h header file must be explicitly included to use GetExceptionCode.

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 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.

The following code example shows the structure of a try-except statement.

try 
{ 
    // try block 
} 
except (FilterFunction(GetExceptionCode()) 
{ 
    // exception handler block 
} 

In the case of nested try-except statements, the filter expression of each statement 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.

When handling the breakpoint exception, the instruction pointer in the context record must be incremented to continue from this exception.

Exceptions that occur across PSL boundaries should behave just like exceptions across functions in the same process, with the exception that the exception can not be continued with EXCEPTION_CONTINUE_EXECUTION.

Requirements

Header excpt.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

Exception Functions
GetExceptionInformation
RaiseException