How to disable all exception raising in Delphi?

风格不统一 提交于 2020-01-13 11:26:09

问题


Is there a way to disable all the dialog boxes when an exception or error occurs(like access violations, indy socket errors, timeouts etc.)? They are thrown sometimes in my program, but these errors aren't fatal in any way and can be ignored, just the dialog boxes are disturbing. I use Delphi 7.


回答1:


If you just don't wont to show the exception window then go to:

Tools/Options/Debugger Options/Language Exceptions and disable CheckBox Notify on language exceptions. That is walid for Delphi 2010.

(I don't remember if it is the same CheckBox in Delphi 7).

EDIT: In some cases the exceptions are unavoidable, specially when we are working with unknown files from internet. So, I believe that your exceptions are handled properly under Indy, just switch-off Notify on language exceptions




回答2:


You can customize Application.OnException event. But IMVHO...

  • Application.OnException suits best to log exceptions which you forgot to handle.
  • Application.OnException should be used to catch exceptions only when you desperately need performance (in this case you should anticipate broken execution paths).

And:

  • Access violations are fatal errors - you have to trace and get rid of all AV's.
  • You can't hide exception dialogs just by Application.OnException override - you should use try finally/except in right way.



回答3:


Bypass the Application.OnException event. However I would NOT recommend hiding every exception, IMHO that is poor design.




回答4:


@ GJ - Delphi 2007 has that check box. But again as was mentioned above, access violation ain't the kind of exceptions that one should ignore.



来源:https://stackoverflow.com/questions/11020561/how-to-disable-all-exception-raising-in-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!