Tutorial :turn off delphi exceptions in run time in delphi


is there any way to turn off exception message showing during run-time in Delphi application? i think there must be a directive to turn off exception message but i cant remember it.


Most exception messages can be suppressed by handling the TApplication.OnException event. The application object only displays an exception message if there isn't a handler assigned to that event. You're welcome to call TApplication.ShowException in your handler for certain exceptions if you want.

That event is fired for exceptions that occur while running in the VCL message loop. Exceptions that occur elsewhere terminate either your program or the current thread. Also, the event is fired only for exceptions that descend from Exception; exceptions that descend from other classes are passed directly to SysUtils.ShowException.

Whether you display a message or not, your program is still in an indeterminate state once an exception has occurred that you haven't handled. Merely suppressing the message is akin to sweeping the dust under the rug. A better course of action is to use an exception-logging tool like MadExcept, EurekaLog, or JclDebug that records information about the exception and gives your customers the option of sending the reports back to you so you can reproduce the conditions of the error and fix it.


I use the IDE to turn it off:

In Delphi 2007, click Tools / Options and go right down to Debugger Options / CodeGear debuggers / Native OS Exceptions. Select "Run Unhandled". The debugger will not halt on exceptions, but act the same as running from an exe. Exceptions will be handled as such.

For directives, I don't know of one that can exactly do the above, but maybe this will help:



Are you running OpenGL by any chance? I've not tried it with the more recent Codegear/OpenGL builds, but there used to be an issue that OpenGL didn't disable FPU exceptions but the IDE expected these to be turned off by default (as Microsoft libraries do) so the IDE would report FPU exceptions ad-nauseam despite these being of no consequence.

The solution was to explicitly turn of FPU exceptions, which you can do in code using the statement.


There may be other libraries where this causes an issue too.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »