Python faulthandler show error window
Question: I might be totally overlooking something but is there a way to show a custom
error window when while using the `faulthandler` package.

Currently I'm just writing to a log file using:

    
    
    faulthandler.enabled(file=open("crash.log", "w")) 
    

however it would be really nice to be able to show some kind of window to the
user with an error message.

Any ideas on how I can do this?


Answer: There is no way to change the behaviour of
[faulthandler](https://pypi.python.org/pypi/faulthandler) to do something
different other than log faults to a file-like object according to the
[documetnation](https://docs.python.org/3/library/faulthandler.html)

However you can change
[`sys.excepthook`](https://docs.python.org/2/library/sys.html#sys.excepthook)
and use a
[`PyQt4.QtGui.QMessageBox`](http://pyqt.sourceforge.net/Docs/PyQt4/qmessagebox.html)

**Example:**

    
    
    #!/usr/bin/env python
    
    import sys
    
    
    from PyQt4.QtGui import QMainWindow, QMessageBox
    
    
    class App(QMainWindow):
    
        def __init__(self, parent=None):
            QMainWindow.__init__(self, parent)
    
            sys.excepthook = self._displayError
    
        def _error(self, etype, evalue, etraceback):
            QMessageBox.critical(
                self,
                "ERROR",
                "An unexpected error occurred: {0:s}".format(evalue)
            )
    

