Cristian Peța 103 Posted February 6, 2020 I just realized that exception messages are shown only for main thread. I'm right? And if yes, why? madExcept will show exception for all app threads and I was surprised to see that without madExcept you can see exceptions for other threads only debugging from IDE. Share this post Link to post
Uwe Raabe 2057 Posted February 6, 2020 It is probably related to this code in System.Classes.ThreadProc: try Thread.Execute; except Thread.FFatalException := AcquireExceptionObject; end; You should be able to get any exception in the threads OnTerminate handler reading its FatalException property. See also http://docwiki.embarcadero.com/Libraries/Rio/en/System.Classes.TThread.FatalException 1 Share this post Link to post
David Heffernan 2345 Posted February 6, 2020 All UI happens from the UI thread. So if you want an exception from another thread to result in UI, you need to marshal it into the main thread. Having madExcept in your process is great. But there are a class of exceptions that you don't want to trouble the user with a bug report. I call these expected exceptions. You need to decide on a policy for those exceptions. Share this post Link to post
Hafedh TRIMECHE 1 Posted February 7, 2020 You may try this code: procedure GlobalExceptionHandler(ExceptionObj:TObject); var LException : Exception; begin if (ExceptionObj is Exception) then LException := Exception(ExceptionObj) else LException := nil; TExceptionHandler.ProcessException(nil,LException); end; constructor TExceptionHandler.Create; begin inherited; JclStackTrackingOptions := [stStack,stRawMode,stTraceAllExceptions]; JclStartExceptionTracking; Application.OnException := ProcessException; ExceptionAcquired := @GlobalExceptionHandler; end; destructor TExceptionHandler.Destroy; begin StopExceptionHandler; inherited; end; It worked for me ! Share this post Link to post