Page 1 of 1

Event viewer

Posted: Wed Aug 31, 2016 6:07 am
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

Re: Event viewer

Posted: Wed Aug 31, 2016 7:26 am
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.

Re: Event viewer

Posted: Wed Aug 31, 2016 8:30 am
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

Re: Event viewer

Posted: Wed Aug 31, 2016 8:40 am
by madshi
Set "handled := true" to disable the normal behaviour.

Re: Event viewer

Posted: Wed Aug 31, 2016 8:44 am
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

Re: Event viewer

Posted: Wed Aug 31, 2016 8:47 am
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.

Re: Event viewer

Posted: Wed Aug 31, 2016 8:50 am
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

Re: Event viewer

Posted: Wed Aug 31, 2016 8:52 am
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.

Re: Event viewer

Posted: Wed Aug 31, 2016 9:08 am
by etwoss
Hi

Email send

Eric

Re: Event viewer

Posted: Wed Aug 31, 2016 9:20 am
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.

Re: Event viewer

Posted: Wed Aug 31, 2016 9:25 am
by etwoss
Thanks!