How to manually save a bug report.

delphi package - automated exception handling
Post Reply
luciano_f
Posts: 47
Joined: Thu Feb 01, 2018 5:11 pm

How to manually save a bug report.

Post by luciano_f »

I made the following code:

Code: Select all

Var I : Integer;
Var madSettings: IMEModuleSettings;

Begin
 Try

  I := StrtoInt('AAA');

 Except

  madSettings := MESettings();
  madSettings.ListThreads := false;
  madSettings.ShowCpuRegisters := false;
  madSettings.ShowStackDump := false;
  madSettings.ShowDisAsm := false;
  madSettings.ShowRelativeAddrs := true;
  madSettings.ShowRelativeLines := true;
  CreateBugReport(etNormal, nil, nil, 0, 0, 0, nil, false, madSettings);

 End
But this code does not save in the file "bugreport.txt"

What should I do to get this code saved in the Txt file?
luciano_f
Posts: 47
Joined: Thu Feb 01, 2018 5:11 pm

Re: How to manually save a bug report.

Post by luciano_f »

I was able to solve using the following code below

Var I : Integer;
Var madSettings: IMEModuleSettings;
Var BugTxt : String;

Begin
Try

I := StrtoInt('AAA');

Except

madSettings := MESettings();
madSettings.ListThreads := false;
madSettings.ShowCpuRegisters := false;
madSettings.ShowStackDump := false;
madSettings.ShowDisAsm := false;
madSettings.ShowRelativeAddrs := true;
madSettings.ShowRelativeLines := true;
madSettings.AutoSave := True;

BugTxt := CreateBugReport(etNormal, nil, nil, 0, 0, 0, nil, false, madSettings);

AutoSaveBugReport(BugTxt, madSettings);

End
luciano_f
Posts: 47
Joined: Thu Feb 01, 2018 5:11 pm

Re: How to manually save a bug report.

Post by luciano_f »

I found a problem in this code I showed above.

It can not clear the data of BugReportHeader where I do with this code below :

The AutoSaveBugReport command ignores this code below and saves all the headers :

procedure RemoveCommandLineHeaderInfo(const exceptIntf : IMEException; var handled : boolean);
begin
exceptIntf.BugReportHeader['registered owner'] := EmptyStr;
exceptIntf.BugReportHeader['display mode'] := EmptyStr;
exceptIntf.BugReportHeader['process id'] := EmptyStr;
exceptIntf.BugReportHeader['allocated memory'] := EmptyStr;
exceptIntf.BugReportHeader['largest free block'] := EmptyStr;
exceptIntf.BugReportHeader['executable'] := EmptyStr;
exceptIntf.BugReportHeader['compiled with'] := EmptyStr;
exceptIntf.BugReportHeader['madExcept version'] := EmptyStr;
exceptIntf.BugReportHeader['callstack crc'] := EmptyStr;

handled := False;

end;

initialization
RegisterExceptionHandler(RemoveCommandLineHeaderInfo, stDontSync);
luciano_f
Posts: 47
Joined: Thu Feb 01, 2018 5:11 pm

Re: How to manually save a bug report.

Post by luciano_f »

After much searching I was able to solve with the following code ::

Code: Select all

Procedure TForm1.Proc_LogErro(E : Exception);
Var madSettings: IMEModuleSettings;
Var exceptIntf : IMEException;
Var BugTxt : String;
Begin

  madSettings := MESettings();
  madSettings.ListThreads := false;
  madSettings.ShowCpuRegisters := false;
  madSettings.ShowStackDump := false;
  madSettings.ShowDisAsm := false;
  madSettings.ShowRelativeAddrs := true;
  madSettings.ShowRelativeLines := true;
  madSettings.AutoSave := True;
  madSettings.ShowPleaseWaitBox := False;

  With NewException(etHidden, E, nil, True, 0, 0, 0, 0, madSettings) do begin
   BugReportHeader['operating system'] := EmptyStr;
   BugReportHeader['system language'] := EmptyStr;
   BugReportHeader['registered owner'] := EmptyStr;
   BugReportHeader['display mode'] := EmptyStr;
   BugReportHeader['process id'] := EmptyStr;
   BugReportHeader['largest free block'] := EmptyStr;
   BugReportHeader['executable'] := EmptyStr;
   BugReportHeader['compiled with'] := EmptyStr;
   BugReportHeader['madExcept version'] := EmptyStr;
   BugReportHeader['callstack crc'] := EmptyStr;

   BugTxt := BugReport;
  End;

  AutoSaveBugReport(BugTxt, madSettings);

End;
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to manually save a bug report.

Post by madshi »

Generally, "MESettings()" gives you access to the global settings. So if you change that, you change it for all future exceptions. If you just want to change the settings for the one "save bug report" action, it makes more sense to use "NewException()" (as you already did), and then change all the settings on the IMEException interface. So I'd suggest that you don't use MESettings() in your code at all. Instead move the "ListThreads := false" and all the other things into the "with NewException()" block. The IMEException interface returned by NewException() inherits from the IMESettings interface, so you can change all the settings directly in the NewException() returned interface. Doing that will then only affect this one "save bug report" action, but will not modify the global settings.
luciano_f
Posts: 47
Joined: Thu Feb 01, 2018 5:11 pm

Re: How to manually save a bug report.

Post by luciano_f »

I got grateful for the information.
Post Reply