0

I learned that PyQt silences the error, and this issue can be resolved by rewriting sys.excepthook. Moreover, I have consulted this two posted link1 and link2, both of which are about the same issue.

However, I could not figure out what sys.excepthook does and how to transfer other`s solution to solve my own problem. Hopefully, you guys can shed me some light on this.

I have class Model with function,

def updateFilename(self, filename):
    if filename is None:
        raise type_exc.PathIsEmpty("You have not chosen any file yet")
    else:
        self._filename = filename

And then, in another file,

def encodeVideo(self):
    try:
        self.model.updateFilename(self.fileName)
    except type_exc.PathIsEmpty as e:
        self.errorDialog.errorTypeChanged(e)
        self.errorDialog.show()

My intention is to use try except as usual, and activate an error displaying dialog when error occurs. But what my code really does, is autonomously exiting when an error takes place.

yujuezhao
  • 1,015
  • 3
  • 11
  • 21
  • Run the code in a console (or command window) so that you can see the traceback. And see [this answer](https://stackoverflow.com/a/33741755/984421). – ekhumoro Jun 01 '19 at 18:11
  • @ekhumoro Thanks, it helps me debug an error which prevents my code functioning as expected. For the record, `try except` works in my case without manipulating with `sys.excepthook` . – yujuezhao Jun 02 '19 at 02:00

0 Answers0