Reputation: 9
I have a Delphi 12 application that uses TIdTCPServer, TThreadProcess... and stuff like that. Occasionally it throws exceptions when debugging, but it doesn't mark the line that generated the exception. I get some like this: "emonitor lockexception unlock list object lock not owned"...but it doesn't mark the line of code that generated it....and it doesn't always happen.
Is there a way to handle all exceptions globally and know in which line they were generated or at least in which procedure or function they were generated?
Upvotes: 0
Views: 31
Reputation: 595019
Unfortunately, there is no single place where you can catch ALL exceptions in ALL threads. Each thread is responsible for catching and handling its own exceptions. If a thread does not catch an exception, the thread is terminated.
In the case of the main UI thread, most exceptions raised in UI event handlers will end up in the TApplication.OnException
event. But, this is really dependent on code catching exceptions and passing them to TApplication.HandleException()
(which the RTL/VCL does in many places).
For TIdTCPServer
, however, its threads catch all exceptions internally and fire the server's OnException
and OnListenException
events. So, you will never see these exceptions in the TApplication.OnException
event.
I don't know what TThreadProcess
is. You will have to look at how it handles/reports exceptions.
Upvotes: 0