I would like to save the log to database. The problem is that I cannot catch when madExcept finishes the file.
I use this code
procedure TMainForm.MadExceptionHandlerException(const exceptIntf: IMEException;
var handled: Boolean);
Begin
try
exceptIntf.BugReportFile :=ExtractFilePath(ParamStr(0)) + 'MyExport\H\' + 'H.txt';
exceptIntf.ScreenShot.SavePng(ExtractFilePath(ParamStr(0)) + 'MyExport\H\' + 'H-.png');
Finally
MyProcedureSaveFilesToDatabase; // <- when I run this the file is still being created, so ExtractFilePath(ParamStr(0)) + 'MyExport\H\' + 'H.txt'; doesn't exists yet
End;
Any ideas? Thank you.
Catch the time when madExcept finishes the file
Re: Catch the time when madExcept finishes the file
Hello,
BugReportFile may not exist yet to work with inside your finally routine however exceptIntf.BugReport should already be filled at that moment and the string contents are the exact contents that are saved to BugReportFile. You could use the string contents directly instead. I imagine you're probably just opening the file anyhow once on disk? You wouldn't have to by using the string directly
--Iconic
BugReportFile may not exist yet to work with inside your finally routine however exceptIntf.BugReport should already be filled at that moment and the string contents are the exact contents that are saved to BugReportFile. You could use the string contents directly instead. I imagine you're probably just opening the file anyhow once on disk? You wouldn't have to by using the string directly
--Iconic
Re: Catch the time when madExcept finishes the file
You can use RegisterExceptionHandler with the epCompleteReport parameter. However, if the user presses "close application" before the bug report is complete, you won't get notified at all.starhu wrote:The problem is that I cannot catch when madExcept finishes the file.
Re: Catch the time when madExcept finishes the file
P.S: I'm not sure from the top of my head about the exact order in which madExcept does everything. It's possible even epCompleteReport handlers are called before the bug report file is actually written to disk. So as iconic suggested, it might make sense to not rely on madExcept's writing of the bug report file, but to instead grab the bug report directly from "excepIntf" by calling "exceptIntf.BugReport". However, if you do this from a "normal" exception handler (instead of epCompleteReport), you force madExcept to block and wait for the creation of the bug report to complete. Which is otherwise done in a background thread.
Practically, if you call exceptIntf.BugReport e.g. within a epQuickFiltering handler, you delay the creation of the exception box, because madExcept is forced to first complete the creation of the full bug report, because your handler returns. By default, madExcept first shows the exception box, with only partial information, and then updates it when the bug report is complete. This approach has the big advantage that the exception box can be shown almost immediately.
Practically, if you call exceptIntf.BugReport e.g. within a epQuickFiltering handler, you delay the creation of the exception box, because madExcept is forced to first complete the creation of the full bug report, because your handler returns. By default, madExcept first shows the exception box, with only partial information, and then updates it when the bug report is complete. This approach has the big advantage that the exception box can be shown almost immediately.