Event viewer

delphi package - automated exception handling
Post Reply
etwoss
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Event viewer

Post by etwoss »

Hi

My boss thinks that having an additional option to log the errors in the Windows Event Viewer would be a nice option.
What do you think?

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

Re: Event viewer

Post by madshi »

That should be very easy for you to implement yourself by using "RegisterExceptionHandler" or "RegisterExceptActionHandler". Probably just a couple of source code lines. madExcept allows you to customize it very easily, with very few source code lines, without having to edit madExcept.pas.

I guess I could also think about adding this functionality to madExcept at some point, but I'm currently busy working on other projects, so it probably wouldn't come soon. But as I said, it should be very easy for you to implement yourself. In your exception handler you have access to all the exception information through the "exceptIntf: IMEException" interface, which is passed as a parameter to your callback function.
etwoss
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Post by etwoss »

Hi

So my own Excepionhandler is called , but still the normal behaviour (in my case mailing a bugreport) is also executed?

Code:

Code: Select all

    RegisterExceptionHandler(ExceptionFilter,stDontSync);

procedure ExceptionFilter(const exceptIntf : IMEException;
                          var handled      : boolean);
begin
  MsgError(exceptIntf.ExceptMessage);
end;

When raising an error, madexcept bugreport is created but my own handler is not called

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

Re: Event viewer

Post by madshi »

Set "handled := true" to disable the normal behaviour.
etwoss
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Post by etwoss »

Hi


What ik wanted to tell that my own handler in this case is not called (tested with a normal EXE)

In my client , the only thing i want to do is show the client the error in a messagebox , but let madExcept also send the bugreport.

also tried

procedure RegisterExceptionHandler (exceptHandler: TExceptEvent;
sync : TSyncType;
phase : TExceptPhase = epMainPhase); overload;

Eric
Last edited by etwoss on Wed Aug 31, 2016 8:48 am, edited 1 time in total.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Event viewer

Post by madshi »

Is it possible you installed your callback too late (after the crash occurred), for some reason? Not sure what else it could be. I've never heard of an exception callback not being called before.
etwoss
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Post by etwoss »

Hi

in the dpr i already call my method SetMadExceptSettings('INFOmatch', True);

In this code i register the handler.
So should work right?

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

Re: Event viewer

Post by madshi »

Depends on where the crash occurs.

Can you reproduce this problem in a brand new (almost empty) test project? If so, you can send me the test project and I can have a look at it.
etwoss
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Post by etwoss »

Hi

Email send

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

Re: Event viewer

Post by madshi »

Your code does "MESettings.GeneralNoHandlers := False". This line disables the calling of all exception handlers for all exceptions.

One hint: "MESettings()" is a function which dynamically creates an IMESettings interface. Your code is ok, but you could improve performance a bit by using "with MESettings() do begin". That way you'd call MESettings() only once instead of a hundred times.
etwoss
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Post by etwoss »

Thanks!
Post Reply