Breaking On Exception

Related Topics:

Special Event Breakpoints Breakpoints Window
Breakpoint Types

You can set an On Exception breakpoint to stop program execution when a C++ throw statement is executed.

Exceptions signal programming anomalies, such as division by zero or array overflow. To deal with these exceptions, you can set up try blocks to catch exceptions that have been raised by throw expressions defined earlier in the code.

You can use an On Exception breakpoint to:

If you step after stopping at a throw point, control is returned at the start of the first destructor that is executed during stack unwinding. If you step out of a destructor control is returned at the start of the next destructor. When all the destructors have been executed, stepping brings you to the catch block handling the throw.

To set an On Exception breakpoint:

1. In the Debugging Window, choose Windows Breakpoints or Execute Set Breakpoints.

2. If the Details pane of the Breakpoints window is not displayed, click the Add/Change Breakpoint button (the Add/Change Breakpoint window toggles to Hide Details).

3. Choose Event On Exception.

You have the option to type a type name. If you type a type name, the program suspends when a C++ throw of that type is executed.

4. If you leave this field blank, any C++ throw statement causes this event.

5. Choose Action Stop.

6. Click Add.