[PyQt] Handling the uncaught exceptions

Sundance sundance at ierne.eu.org
Fri Jan 25 09:19:41 GMT 2008


Hi Peter,

> Is there a way to handle the uncaught exceptions that happen in PyQt?

Yup: install your own exception handler in sys.excepthook.

You'll find a somewhat fancy exception handler I wrote a while back as 
the handle_exception() function (starting line 146) in this file:
http://spyrit.svn.sourceforge.net/viewvc/spyrit/trunk/Utilities.py?revision=99&view=markup

The gist of it is, any function that takes the parameters exc_type, 
exc_value and exc_traceback, and DOESN'T use exceptions internally, 
will serve. Do note that your PyQt application will /not/ exit after 
calling the exception handler, so if you want that, call sys.exit() 
right in your exception handler.

HTH,

-- S.


More information about the PyQt mailing list