Event viewer

delphi package - automated exception handling

Event viewer

Postby etwoss » Wed Aug 31, 2016 6:07 am

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
etwoss
 
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Postby madshi » Wed Aug 31, 2016 7:26 am

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.
madshi
Site Admin
 
Posts: 9431
Joined: Sun Mar 21, 2004 5:25 pm

Re: Event viewer

Postby etwoss » Wed Aug 31, 2016 8:30 am

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
etwoss
 
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Postby madshi » Wed Aug 31, 2016 8:40 am

Set "handled := true" to disable the normal behaviour.
madshi
Site Admin
 
Posts: 9431
Joined: Sun Mar 21, 2004 5:25 pm

Re: Event viewer

Postby etwoss » Wed Aug 31, 2016 8:44 am

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.
etwoss
 
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Postby madshi » Wed Aug 31, 2016 8:47 am

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.
madshi
Site Admin
 
Posts: 9431
Joined: Sun Mar 21, 2004 5:25 pm

Re: Event viewer

Postby etwoss » Wed Aug 31, 2016 8:50 am

Hi

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

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

Eric
etwoss
 
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Postby madshi » Wed Aug 31, 2016 8:52 am

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.
madshi
Site Admin
 
Posts: 9431
Joined: Sun Mar 21, 2004 5:25 pm

Re: Event viewer

Postby etwoss » Wed Aug 31, 2016 9:08 am

Hi

Email send

Eric
etwoss
 
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am

Re: Event viewer

Postby madshi » Wed Aug 31, 2016 9:20 am

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.
madshi
Site Admin
 
Posts: 9431
Joined: Sun Mar 21, 2004 5:25 pm

Re: Event viewer

Postby etwoss » Wed Aug 31, 2016 9:25 am

Thanks!
etwoss
 
Posts: 23
Joined: Thu Aug 04, 2016 11:45 am


Return to madExcept

Who is online

Users browsing this forum: No registered users and 2 guests