Catching all (otherwise uncaught) exceptions?

In a wxPython app, is there anywhere I can catch all
uncaught exceptions?

I'm hoping to be able to be able to catch any exceptions
and throw up a warning dialog box to the user.

Thanks,
  Tom

I have a way, but it doesn't always work across multiple threads(and I'm not
sure why yet). Somewhere in your App call catchUncaughtExceptions with a
window as an argument.

If you don't use threads at all you can probably lose the
ExceptEvent class, wxEVT_UNCAUGHT_EXCEPTION, wxPost, etc, and just make
_excepthook display the dialog.

wxEVT_UNCAUGHT_EXCEPTION = wxNewEventType()
class ExceptEvent(wxPyEvent):
  def __init__(self, value, trace, exctype):
    wxPyEvent.__init__(self)
    self.SetEventType(wxEVT_UNCAUGHT_EXCEPTION)
    self.value = value
    self.trace = trace
    self.exctype = exctype

def _excepthook(exctype, value, trace):
  evt = ExceptEvent(value, trace, exctype)
  wxPostEvent(_exceptwin, evt)

def _excepthandler(evt):
  errorBox(_exceptwin, str(evt.value))

_exceptwin = None
def catchUncaughtExceptions(win):
  global _exceptwin
  _exceptwin=win
  win.Connect(-1, -1, wxEVT_UNCAUGHT_EXCEPTION, _excepthandler)
  sys.excepthook = _excepthook

Jason

···

On Wed, Feb 19, 2003 at 04:17:19PM +1100, Tom McDermott wrote:

In a wxPython app, is there anywhere I can catch all
uncaught exceptions?

I'm hoping to be able to be able to catch any exceptions
and throw up a warning dialog box to the user.