Skip to content

Categories:

MadExcept (and SmartInspect)

We use MadExcept, an Exception/Error reporting tool which sends reports including screenshots per eMail to us, since several years and I can highly recommend it. It’s so easy to implement, just recompile your code and you are done. But there are several possibilities where you have to write your own exception handler to use them. This way, we spice up our results with additional information like the application name and version number. Since we use SmartInspect we add this log file (here is another example of this)  to the report as well as another log generated by our burning engine. SmartInspect-Logging in our applications is turned off by default, but can enabled by registry key. We only enable logging on support requests (and during development). But MadExcept itself is enabled all the time.

Sometimes it is useful to send a report by request (not on an error), so we added an menu item which raises a specific exception (TSendUserReportException), which is handled specifically. We use an custom exception handler like that:

unit AdditionalMadExceptInfo;

[...]

procedure AddAdditionalExceptionInfo(const exceptIntf: IMEException; var Handled: Boolean);
var
  BugRepPath: string;
  BugRepFile: string;
  Sil, BurnLog: string;
  assistant: INVAssistant;
  ss: INVBitmap;
begin
  // place Bugreport in writeable directory
  if Pos('\', MESettings.BugReportFile) = 0 then
  begin
    BugRepPath := GetAppDataDir;
    BugRepFile := 'bugreport_' + ChangeFileExt(ExtractFileName(ParamStr(0)), '.txt');
    MESettings.BugReportFile := BugRepPath + BugRepFile;
  end;

  // add useful information and change email subject, to make it easier to filter
  exceptIntf.BugReportHeader.Add('AppVersion', Version);
  exceptIntf.BugReportHeader.Add('AppName', ApplicationCompany + ' ' + ApplicationTitle);
  exceptIntf.MailSubject := '[BugReport] ' + ApplicationTitle + ' ' + Version + ' "' + exceptIntf.ExceptMessage + '"';
  exceptIntf.BugReportHeader.Add('user report', 'no');

  // User clicked on "Send Bug Report" in Main Menu
  if (exceptIntf.ExceptClass = TSendUserReportException.ClassName) then
  begin
    exceptIntf.BugReportHeader.Add('user report', 'yes');
     // disable useless report parts
    exceptIntf.SuspendThreads := False;
    exceptIntf.ShowPleaseWaitBox := False;
    exceptIntf.ShowStackDump := False;
    exceptIntf.ShowDisAsm := False;
    exceptIntf.ShowCpuRegisters := False;
    exceptIntf.ListThreads := False;
    exceptIntf.MailAddr := sUserReports;

     // manually show MadExcepts report window
    assistant := exceptIntf.GetAssistant(exceptIntf.SendAssistant);
    assistant.Title := sSendErrorReport;

    if (assistant.ShowModal(0) = nvmOK) then
    begin
      PutAssisIntoBugReport(assistant, exceptIntf);

      if (exceptIntf.AppendScreenShot) then
        ss := exceptIntf.ScreenShot
      else
        ss := nil;

      // Attach SmartInspect Log-File
      sil := GetLogFile;
      if FileExists(sil) then exceptIntf.AdditionalAttachments.Add(sil);

      // Attach Burn Log-File
      if FileExists(BurnLog) then exceptIntf.AdditionalAttachments.Add(BurnLog);

      exceptIntf.ListThreads := False;

      SendBugReport(exceptIntf.GetBugReport(True), ss, 0, exceptIntf);
    end;
    Handled := True;
  end;
end;

initialization
  RegisterExceptionHandler(AddApplicationInfoHeaderInfo, stDontSync);
end.

Posted in Delphi, Tools. Tagged with , , , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.