For debugging/diagnostic purposes I'm looking for a way to invoke some
custom code whenever an unhandled exception occurs in any event handler.
That is to say, I'd rather not have to put it in every event handler -
I'd like it to act on all events within my application (or at least
those handled in non-wx code). Here's what I've come up with so far:
1) I found wxApp::HandleEvent in the docs which looks like it is
designed exactly for my purposes, but it also looks like it is for C++
only.
2) Override stdout/stderr, but the information I'd receive at this point
is too unstructured to be of much use.
3) I could write a custom exception hook (Python's sys.excepthook).
Since wxPython prints out unhandled exceptions, the except hook would be
invoked with my code in it. From this point I don't know how to access
information about the event that was being processed which would be very
useful.
I think #3 is the best approach I've come up with so far. Is the event
currently being processed stored anywhere that I could get at? It just
occurred to me that I might be able to look at the deepest level in the
traceback (which appears to always be the event handler) and assume the
last parameter is the event - I'm not sure how reliable that would be.
Does anybody have any ideas or experience with this sort of thing?
Thanks,
Jimmy