turn off delphi exceptions in run time in delphi

前端 未结 3 2039
执笔经年
执笔经年 2021-01-24 07:35

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

3条回答
  •  没有蜡笔的小新
    2021-01-24 08:24

    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.

提交回复
热议问题