Can MadExcept report be created even if code catches except?

delphi package - automated exception handling
Post Reply
manojt
Posts: 5
Joined: Wed Apr 01, 2015 5:25 pm

Can MadExcept report be created even if code catches except?

Post by manojt »

Is it possible to configure Madexcept in such a way that it creates a report even in cases where my code catches the exception?
For example: for the following procedure, I do want to configure so that MadExcept will generate the bug report and save it before program control goes to the except code block.
In summary, I want to be able to create MadExcept report for any exception whether it is handled in the code or not. Please let me know if it is possible. Thank you!

Code: Select all

procedure foo;
var
o : TObject;
s: string;
try
  s := o.ClassName;
except
  on e: Exception do begin
      s := 'Unassigned Object';
  end;
end;
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: Can MadExcept report be created even if code catches exc

Post by madshi »

Do you want madExcept to become active in this situation just the same way as it would without that try..except block? Do you want to manually invoke madExcept in such try..except blocks or do you want madExcept to automatically do that for each and every try..except block in your application?
manojt
Posts: 5
Joined: Wed Apr 01, 2015 5:25 pm

Re: Can MadExcept report be created even if code catches exc

Post by manojt »

Thanks for the reply.
Yes, we want it to become active as it would without the try, but with the difference that the control then to be passed on to the except block.
(Configured as 'Don't show anything' for any exception, Automatically Save bug report, automatically continue application).
Code exists already and would be not possible to manually insert every where. Appreciate the support!
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: Can MadExcept report be created even if code catches exc

Post by madshi »

Ok, this should do the trick:

Code: Select all

uses ..., madExcept;

procedure ForceHandlingOfHiddenExceptions(const exceptIntf: IMEException; var handled: boolean)
begin
  handled := false;
end;

initialization
  RegisterHiddenExceptionHandler(ForceHandlingOfHiddenExceptions, stDontSync);
end.
manojt
Posts: 5
Joined: Wed Apr 01, 2015 5:25 pm

Re: Can MadExcept report be created even if code catches exc

Post by manojt »

Thank you so much! Do I have to do this at each class level/unit?
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: Can MadExcept report be created even if code catches exc

Post by madshi »

No, just once somewhere in one unit, doesn't matter much which.
manojt
Posts: 5
Joined: Wed Apr 01, 2015 5:25 pm

Re: Can MadExcept report be created even if code catches exc

Post by manojt »

Thank you!
manojt
Posts: 5
Joined: Wed Apr 01, 2015 5:25 pm

Re: Can MadExcept report be created even if code catches exc

Post by manojt »

I tried it out and worked!! Thanks a loooot!
Post Reply