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);
begin
  // 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;
end;

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

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

    try
      // put the bug report data into the TStringStream
      InStream.WriteString(ExceptIntf.BugReport);

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

      // encrypt with LockBox DES encryption
      LockBoxDES.EncryptStream(InStream,OutStream);
    finally
      // free the streams
      InStream.Free;
      OutStream.Free;
    end;
  end;
end;


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?
bwdirks
 
Posts: 2
Joined: Wed Feb 04, 2015 7:07 pm

Return to madExcept

Who is online

Users browsing this forum: No registered users and 6 guests