In its default settings, the Delphi IDE notifies you whenever an exception occurs in your program, as in Figure 1. What’s important to realize is that at that point, none of your program’s exception-handling code has run yet. It’s all Delphi itself; its special status as a debugger allows it to get first notification of any exception in your program, even before your program knows about it.
Figure 1
An IDE-generated dialog box notifying that an exception occurred in the program being debugged

After you dismiss Delphi’s message box, execution will be paused
at the best line of your source code Delphi could find to represent the
source of the exception. Press the “Run” button to have your
program resume. Control will pass to the next finally or except
block. Before you resume your program, you may use the various debugging
tools at your disposal. You can inspect the values of any variables in
scope, and you can even modify their values.
Avoiding notification
If you do not want to be notified when an exception occurs, you have a few options.
-
You can use Delphi’s “advanced breakpoints” to disable exception handling around a region of code. To begin, set a breakpoint on the line of code where you want the IDE to ignore exceptions. Right-click on the breakpoint dot in the gutter and open the breakpoint-property dialog. In the advanced section are some check boxes. (See Figure 2.) Clear the “Break” box to prevent the debugger from interrupting your program at that line, and set the “Ignore subsequent exceptions” box.
Afterward, set another breakpoint where you want the debugger to resume handling exceptions. Change its properties to handle subsequent exceptions.
Figure 2
The breakpoint-property dialog box with the advanced section visible for changing exception-handling behavior

-
You can tell the debugger to ignore certain kinds of exceptions. Figure 3 shows Delphi’s language-exception options. Add an exception class to the list, and all exceptions of that type and of any descendant types will pass through to your program without Delphi interfering.
Figure 3
Delphi 2005 dialog for controlling language exceptions

-
In an option related to the previous one, you can tell the debugger not to interrupt on any exceptions. To do that, clear the “Notify on language exceptions” check box.
-
Finally, you can turn off integrated debugging altogether. Delphi will not notify you of exceptions, and it will also not stop at breakpoints or allow use of the “Pause” button. Turn off integrated debugging in the debugger options, as shown in Figure 5 for Delphi 2005.
Figure 4
Delphi 2005 dialog for disabling integrated debugging: Clear the “Integrated debugging” check box
