Save Bug Report as ZIP file

delphi package - automated exception handling
Post Reply
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Save Bug Report as ZIP file

Post by FredS »

Hi Mathias,

I am wondering if there is a way to have the "Save Bug Report" button save in the same format as the "Send Bug Report" button?

I already implemented the SendBugReport to work by sending a Zip file which contains a log file we need.
But when clicking Save Bug Report I only get the txt of the BugReport, apparently it skips the added code in the MadExceptionHandlerException:

Code: Select all

      Log.CloseFile; // mad won't attach unless its closed
      exceptIntf.AdditionalAttachments.Add(Log.FileName, 'Info.log', AssistDatazip, 'LOGFILE'); // add an attachment
      exceptIntf.ScreenShotZip := AssistDatazip;
      exceptIntf.BugReportZip := AssistDatazip;
      Log.Append := True; // Don't overwrite log for new LogPrints
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Save Bug Report as ZIP file

Post by madshi »

Hi Fred,

the "save" button is designed to just save the bug report itself, no screenshots or other attachments. It would be difficult to manage other configurations. E.g. if you want a ZIP file to be saved, then every saved bug report would overwrite the previously saved report. That doesn't sound very useful. Currently, the way saving is implemented, the user can press the save button for several exceptions, and they're all appended to the same bug report file. If at one point that bug report file reaches you, you'll find all the bug reports collected in there. Such a solution would be much more complicated to realize for zip files. E.g. I could save zip files with different file names, appending some sort of number of date. But then when to save old reports?

If you really want to have this functionality, you can use RegisterExceptActionHandler() and in your handler simply replace the functionality of the "save bug report" button with your own code. Would cost you a bit of time, but then you have full flexibility.
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: Save Bug Report as ZIP file

Post by FredS »

OK, the other way to look at that is what if there is no mail client?
How do we easily get the full bug report with additional info?

Will take a look at RegisterExceptActionHandler.

thanks

Fred
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Save Bug Report as ZIP file

Post by madshi »

The best approach is probably to use HTTP uploading. You would setup a PHP script on your webserver, and then your application would post the bug report to that script, and the script would turn it into an email. See the bottom of this page:

http://help.madshi.net/madExceptSettings5a.htm
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: Save Bug Report as ZIP file

Post by FredS »

madshi wrote:The best approach is probably to use HTTP uploading.
Not an option, essentially Secure Domains don't like apps that upload "unknown" stuff to a remote site.. well neither do I :wink:

thanks

Fred
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Save Bug Report as ZIP file

Post by madshi »

Well, you can also use SMTP mailing. The key problem with that is that you need to provide an account name and password. One "trick" is to create an extra dummy email account for that, and let it forward the bug reports to your real email address. Or you could setup your own SMTP server, which accepts bug reports without account name and password, as long as some requirements are met (e.g. a bug report attachment or similar).
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: Save Bug Report as ZIP file

Post by FredS »

madshi wrote:Well, you can also use SMTP mailing.
Well I tried to implement an ExceptActionEvent and all was pretty straight forward until I could not get the full path to BugReport. Btw I would appreciate that answer, BugReportFile points to the Filename without path.

But.. while searching for that answer here in the forum I ran into BugReportSections, which solves my problem in a much cleaner way:

Code: Select all

      exceptIntf.BugReportSections.Add('Info.log', GetLogFileContent);

Code: Select all

procedure TMainForm.ExceptActionEvent(Action: TExceptAction; const exceptIntf: IMEException; var Handled: Boolean);
begin
  if Action = eaSaveBugReport then
  try
    SetTopmost(GetExceptBoxHandle, false);
    SavetoDialog.FileName := AssistDatazip;
    if SavetoDialog.Execute([ffZip]) then begin
      AddCriticalLogData;
      with TZipFile.create do
        try
          Open(SavetoDialog.FileName, zmWrite);
          Add(Log.FileName, 'Info.log');
          Add(exceptIntf.BugReportFile, 'Hardware_Stack.mbr');
          Close;
        finally
          Free;
        end
    end;
    Handled := True;
  Except
    On E:Exception do BreakPoint;  // Error is already up we don't need more
  end;
end;
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Save Bug Report as ZIP file

Post by madshi »

exceptIntf.BugReportFile returns the path which is stored in the settings. If there's no path stored there, you won't get a path. However, now that you mention it, it could be useful to get access to the bug report file path, I guess. Although, of course you could also replace the saving and then you'd have everything under full control.

Anyway, adding information to BugReportSections has fully solved your problem?
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: Save Bug Report as ZIP file

Post by FredS »

Anyway, adding information to BugReportSections has fully solved your problem?
Yes, thanks.
Post Reply