turn off delphi exceptions in run time in delphi

前端 未结 3 2014
执笔经年
执笔经年 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:01

    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:

    http://www.delphibasics.co.uk/ByType.asp?Type=Compiler%20Directive

    0 讨论(0)
  • 2021-01-24 08:06

    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.

    Set8087CW($133F);
    

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

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题