How can I ignore an exception?

delphi package - automated exception handling
Post Reply
Han312
Posts: 54
Joined: Mon Mar 14, 2016 3:49 pm

How can I ignore an exception?

Post by Han312 »

For leaks there is a function HideLeak.
Does something similar exist for exceptions?

I would like to ignore TCustomForm.CloseQuery.
Is this possible?
iconic
Site Admin
Posts: 1065
Joined: Wed Jun 08, 2005 5:08 am

Re: How can I ignore an exception?

Post by iconic »

Hello,

You can added classes to a filter rule, something as simple as specified here

http://help.madshi.net/madExceptSettings3.htm

--Iconic
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: How can I ignore an exception?

Post by madshi »

Hmmmm... "TCustomForm.CloseQuery" is not an exception. Can you clarify what you mean exactly?
Han312
Posts: 54
Joined: Mon Mar 14, 2016 3:49 pm

Re: How can I ignore an exception?

Post by Han312 »

We get many exception messages from customers which were caused within of OnFormCloseQuery.

If there are projects which were changed but not saved then we pop up a message to ask what to do.
Now we have customers who have open projects and want to shut down windows.

Or we open a dialog box after starting the program but the user only started the software and then shuts the system down.

The explorer shows them that we expect a customer reaction - but they ignore it and continue to shut down.

It looks then somehow like

Code: Select all

exception message               : Zugriffsverletzung bei Adresse 0000000000000000 in Modul 'MyProgram.exe'. Ausführung von Adresse 0000000000000000.

main thread ($2a70):
00000000 +0000 ???
0167b34b +02cb MyProgram.exe      MyMainFRM       8824  +97 TMyMainForm.FormCloseQuery
00b55e3a +007a MyProgram.exe      Vcl.Forms                TCustomForm.CloseQuery
00b54322 +0012 MyProgram.exe      Vcl.Forms                TCustomForm.WMQueryEndSession
I would like to be able to switch on/off madexcept when FormCloseQuery is called.
Is that possible?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: How can I ignore an exception?

Post by madshi »

Can you reproduce this problem on your development PC? If so, that would be helpful testing how to solve it in the best way.

There are various options:

1) You could call "PauseMadExcept()" at the start of FormCloseQuery(). However, if you do that and an exception occurs, you'll get the standard Delphi exception box.

2) Or you could add a try..except block around your code in FormCloseQuery().

3) Or you could try to actually find the cause of the crash. It looks like line 8824 of your MyMainFRM.pas jumps to a "nil" pointer, for some reason.

Probably there are even more things you could do, but maybe one of those above already helps?
Han312
Posts: 54
Joined: Mon Mar 14, 2016 3:49 pm

Re: How can I ignore an exception?

Post by Han312 »

The user does not close the software the proper way. Therefore I do not want to invest much time.

So I guess that the least problematic way is to use version 2.
I was so focussed on switching off madexcept that I did not see the most obvious solution. :sorry:
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: How can I ignore an exception?

Post by madshi »

Hehe! Yes, if 2) works for you then yes, it's probably the easiest and "best" solution.
Post Reply