Remove or replace the absolute path of an EAssertionFailed with a relative path or the file name only?

Viewed 548

Is there some way to remove or replace the absolute path of an EAssertionFailed error message? I would like to not include the entire path to not indirectly reveal where the source has been compiled and make the message independent of that location. Preferably the relative path to the project root or to the DPR file, or the source file name only would be included in the error message instead.


Program output:

EAssertionFailed: Assertion failed (C:\Users\User\Documents\
Embarcadero\Studio\Projects\Project3.dpr, line 12)

Project3.dpr

program Project3;

{$AppType Console}

{$R *.res}

uses
  System.SysUtils;

begin
  try
    Assert(False);
  except
    on E: Exception do
    begin
      WriteLn(E.ClassName, ': ', E.Message);
      ReadLn;
    end;
  end;
end.
1 Answers
Related