Chapter 24 Structured Exception Handling

24.1 Structured Exception Handling

This section describes the exception handling capabilities of Win32. An exception is an event that occurs during the execution of a program which requires the execution of software outside the normal flow of control.

Exceptions can result from the execution of certain instruction sequences, in which case they are initiated by hardware. Other conditions may arise as the result of execution a software routine (e.g., an invalid parameter value), and are therefore initiated explicitly by software.

When an exception is initiated, a systematic search is performed in an attempt to find an exception handler that will dispose of (handle) the exception.

An exception handler is a function written to explicitly deal with the possibility that an exception may occur in a certain sequence of code.

Exception handlers are declared in a language-specific syntax and are associated with a specific scope of code. The scope may be a block, a set of nested blocks, or an entire procedure or function.

Exception handling capabilities are an integral and pervasive part of the Win32 system. They enable a very robust implementation of the system software. It is envisioned that application developers will see the benefits of exception handling capabilities and also use them in a pervasive manner.

Structured exception handling is made available to application developers largely through compiler support. Although this chapter will use examples from the support available in Microsoft compilers provided with the initial Win32 development kit, Microsoft will work with other compiler vendors to ensure that they can provide this support as well.