You can indeed use Assert
for this. Write a procedure that matches the signature dictated by the TAssertErrorProc
type, and then do whatever you want there. To preserve the expected behavior, you should probably call the original handler after you're finished.
procedure MichaelAssertProc(const Message, Filename: string;
LineNumber: Integer; ErrorAddr: Pointer);
begin
LogMessage(...);
SysUtils.AssertErrorHandler(Message, Filename, LineNumber, ErrorAddr);
end;
Assign that procedure to System.AssertErrorProc
sometime while your program starts up.
AssertErrorProc := MichaelAssertProc;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…