Add a variable value when exception

delphi package - automated exception handling
Post Reply
emailaya
Posts: 249
Joined: Thu Oct 13, 2005 11:33 am
Contact:

Add a variable value when exception

Post by emailaya »

Hi

I use RegisterExceptionHandler(frmMain.ExceptionFilter, stTrySyncCallOnSuccess); and use my own implementation when an exception occur.

This all works great and my question is, whether I can add a variable value to the report so as an addition to the report itself, I want to know the content of a specific variable so I will know the context of the exception.

Thanks
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Add a variable value when exception

Post by madshi »

Sorry for the late reply.

in your "frmMain.ExceptionFilter" handler you can do "exceptIntf.BugReportHeader['yourVariable'] := yourVariable;".

Does that do what you need?
emailaya
Posts: 249
Joined: Thu Oct 13, 2005 11:33 am
Contact:

Re: Add a variable value when exception

Post by emailaya »

The thing is I have 10 threads (same thread running 10 times each time with a specific code) and if one of them fails, I want to know the code that failed.
If I understand correctly, the exception is running on the main thread so I need a way to catch the code from the thread and somehow send it to the exception handler
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Add a variable value when exception

Post by madshi »

Unfortunately that's more complicated than it sounds. Exception handling runs in its own private thread. However, you can use "exceptIntf.CrashedThreadId" to ask which thread (ID) crashed. I'm not sure if that's enough information for your needs? If not, I suppose you could create a global thread storage (properly synchronized with critical sections, of course) in which you would store information per thread, so in your exception handler you could then extract the information you need from the global thread storage, by using the CrashedThreadId.
Post Reply