Debugging Exceptions
The debugger writes exception messages to the Output window. You can choose whether or not the program should halt or continue processing.
For Stop If Not Handled, the debugger writes a message to the Output window when an exception occurs, but does not halt the program unless the exception handler fails to handle the exception. At that point it is too late to fix the problem or examine the source code to see where the exception occurred because the program is already past the point where the exception occurred and is executing in the exception handler.
For Stop Always, the debugger stops the program and notifies you immediately when an exception occurs, before any handler code is invoked. You can look at the source window to see where the exception occurred, use the Watch and Variables windows and QuickWatch to see variable contents, and attempt to fix the exception yourself by modifying the variable contents. When you continue the program after the exception, a dialog box asks if you want to pass the exception back to the program’s exception handlers. If you fixed the problem, click No. Otherwise, click Yes, and the exception handler is invoked. If the exception handler cannot fix the problem, the debugger halts the program and notifies you as if the exception were Stop If Not Handled.
To set how the debugger handles exceptions
From the Debug menu, click Exceptions.
The Exceptions dialog box opens.
Choose Stop Always or Stop If Not Handled for each exception type that can occur in your program.
The Exceptions list box in the Exceptions dialog box contains a default list of system exceptions. The information is saved in the project.DSW file, which persists with the project. If an exception is not included in this list, the debugger treats it as a Stop If Not Handled exception.
To add a new exception to the Exceptions list box
From the Debug menu, click Exceptions.
The Exceptions dialog box appears.
In the Number box, type the exception number for the user-defined exception.
Optionally, type the name of the exception in the Name box.
Optionally, under Action, select the Stop Always or Stop If Not Handled option.
Click Add.
Click OK.
To change an exception parameter
From the Debug menu, click Exceptions.
The Exceptions dialog box appears.
In the Exceptions list box, select the exception.
Change any parameter, such as the name or the action.
Click Change.
Click OK.
To remove an exception from the Exceptions list box
From the Debug menu, click Exceptions.
The Exceptions dialog box appears.
In the Exceptions list box, select the exception.
Click Remove.
When you delete an exception from the Exceptions list box, its action reverts to Stop If Not Handled.
Click OK.
To restore all default system exceptions to the Exceptions list box
From the Debug menu, click Exceptions.
The Exceptions dialog box appears.
Click Reset.
All default system exceptions are restored to the Exceptions list box without disturbing any of the user-defined exceptions that have been added.
Click OK.