I'm trying to get a complete stacktrace from a FMX client (32 and 64 bit) to our server.
I do not use the build in dialog but want to send the bug message silently to a rest server. The user will get a proper dialog message later.
The whole bug report should end up in a string.
The problem is that GetCrashStackTrace() returns nothing.
procedure HandleWindowsException(const exceptIntf: IMEException; var handled: boolean);
var i: Integer;
begin
var mainReason := 'Exception: ' + exceptIntf.ExceptMessage;
var crashStackTrace := GetCrashStackTrace();
var bugReport := CreateBugReport();
var body := mainReason + '<br/><br/>Stacktrace: ' + crashStackTrace + '<br/><br/><br/>' + bugReport;
// do stuff with body
end;
initialization
RegisterExceptionHandler(HandleWindowsException, stDontSync);
end.
GetCrashStackTrace only works in a try..except block catching the exception. Your handler is called in a different thread, so GetCrashStackTrace won't work.
Anyway, the solution is easy: Just use "exceptIntf.BugReport".
Please note that your callback may be called before the bug report is even fully created, and if you call "exceptIntf.BugReport", that will block until the bug report is available, and while it's blocking, a little progress window is displayed. If you don't want to see the progress window, uncheck the "show please wait box" option here: