Problem RegisterExceptionHandler

delphi package - automated exception handling
Post Reply
EdwardS
Posts: 2
Joined: Wed Nov 04, 2020 8:56 pm

Problem RegisterExceptionHandler

Post by EdwardS »

Hi

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;
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.


I hope you can help.
madshi
Site Admin
Posts: 10338
Joined: Sun Mar 21, 2004 5:25 pm

Re: Problem RegisterExceptionHandler

Post by madshi »

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:

http://help.madshi.net/madExceptSettings2.htm
EdwardS
Posts: 2
Joined: Wed Nov 04, 2020 8:56 pm

Re: Problem RegisterExceptionHandler

Post by EdwardS »

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.
Post Reply