Encrypt the attached bug report file

delphi package - automated exception handling

Encrypt the attached bug report file

Postby bwdirks » Wed Sep 13, 2017 7:09 pm

I'm using LockBox to encrypt the ExceptIntf.BugReportFile. That part is working. I'm encrypting the file within the TMadExceptionHandler.OnExceptAction.
Here's the code:
Code: Select all
procedure TfmTest.FormCreate(Sender: TObject);
  // get the user's temp folder. FErrorFile is a private variable in the form class
  FErrorFile := IncludeTrailingPathDelimiter(GetEnvironmentVariable('TEMP'));

  // append the file name
  FErrorFile := FErrorFile + 'Error.log';

  // tell madExcept where to create the file
  MESettings.BugReportFile := FErrorFile;

procedure TfmTest.MadHandlerExceptAction(action: TExceptAction; const exceptIntf: IMEException; var handled: Boolean);
  InStream: TStringStream;
  OutStream: TFileStream;

  if Action = eaSendBugReport3 then
    InStream  := TStringStream.Create;
    OutStream := TFileStream.Create(ExceptIntf.BugReportFile,fmCreate);

      // put the bug report data into the TStringStream

      // reset position to 0
      InStream.Position := 0;

      // encrypt with LockBox DES encryption
      // free the streams

In my test app I have a line of code that will throw a simple List out of bounds exception. When I run the test app I end up with 2 Error.log files.
One in the correct place, the user's TEMP folder: C:\Users\me\AppData\Local\Temp\Error.log. And it's encrypted.
But another one gets created, that's NOT encrypted, gets created in C:\Users\me\AppData\Local\Temp\MyTest.madExcept\Error.log.

What am I doing wrong?
Posts: 2
Joined: Wed Feb 04, 2015 7:07 pm

Re: Encrypt the attached bug report file

Postby madshi » Tue Sep 19, 2017 5:49 pm

You're writing the file, but you're not telling madExcept that you've done so. If you set "handled := true" madExcept will know that the requested "action" has been executed and that madExcept doesn't have to do anything, anymore. However, looking at your code, you're doing this for the "send" action, not "save" action? In that case setting "handled := true" will actually stop the "send" action, which is probably not what you want?

In any case, my best guess is that you still have the default madExcept setting "automatically save bug report" checked here:


If so, simply unchecking that should get rid of the not encrypted file writing.
Site Admin
Posts: 9376
Joined: Sun Mar 21, 2004 5:25 pm

Return to madExcept

Who is online

Users browsing this forum: No registered users and 4 guests