Recent

Author Topic: How to hide unhandled exceptions in finalization  (Read 998 times)

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
How to hide unhandled exceptions in finalization
« on: August 21, 2019, 09:11:19 am »
Hi,

How to hide error messages about "An unhandled exception occured at..." (EAccessViolation) which may appears on closing of my app? I guess that they appears in finalization code.

We need to hide these errors only in a build for end-users. And see these errors during development to find and fix it. Regrettably we still cannot find and fix all cases because our product is very complex and uses many threads.

I attach a screenshot with similar error from Internet (not our error).

Lazarus 64-bit 2.0.4

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: How to hide unhandled exceptions in finalization
« Reply #1 on: August 21, 2019, 09:37:04 am »
This is not in the finalization code but is the default response dialog from TApplication.HandleException.
You can change this behavior by using the TApplication.OnException event and handle it there.
Another possibility is to override the system.ExceptProc. (E.g.: in console apps)

See here:
https://wiki.lazarus.freepascal.org/Logging_exceptions which has a good explanation.

From what I see the application looks terminated by ctrl-c, which is strictly speaking not an exception (but it is a signal!), that can cause side effects.

BTW: even complex applications should not eat exceptions, they should be debugged and fixed.
There, using the full example in the link above (instead of using the code as a template) can help a lot.
« Last Edit: August 21, 2019, 09:44:45 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
Re: How to hide unhandled exceptions in finalization
« Reply #2 on: August 21, 2019, 10:35:11 am »
Many thanks for your info!

I agree that we should find and fix all these cases with exceptions.

We recently switched from Delphi to Lazarus.


 

TinyPortal © 2005-2018