Problem RegisterExceptionHandler

delphi package - automated exception handling

Problem RegisterExceptionHandler

Postby EdwardS » Wed Nov 04, 2020 9:11 pm


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.

What am I doing wrong?

Code: Select all

procedure HandleWindowsException(const exceptIntf: IMEException; var handled: boolean);
var i: Integer;

   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


  RegisterExceptionHandler(HandleWindowsException, stDontSync);

I hope you can help.
Posts: 2
Joined: Wed Nov 04, 2020 8:56 pm

Re: Problem RegisterExceptionHandler

Postby madshi » Thu Nov 05, 2020 9:26 am

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:
Site Admin
Posts: 10303
Joined: Sun Mar 21, 2004 5:25 pm

Re: Problem RegisterExceptionHandler

Postby EdwardS » Thu Nov 05, 2020 3:39 pm

Its working now!

Thanks for the clear help.

I've also got it silent by setting: handled := true; which is mentioned in another forum thread.
Posts: 2
Joined: Wed Nov 04, 2020 8:56 pm

Return to madExcept

Who is online

Users browsing this forum: No registered users and 12 guests