0

Hi I am still relatively new to pyqt, and wondering what's the besting strategy to handle exceptions.

I am programming an GUI that helps user to process data, and would like the app to at least let users to save the analysis (as json) when a crash happens. Right now even a simple, non-related exception crashes the whole app, like:

foo = dict(20)

Even foo is never used in the code anywhere else.

The strategy I can think of is to add try-catch to places that I expect to throw exceptions, but qt is complicated (to me) and sometimes it's hard to predict where the exceptions will be.

I used to work with matlab-gui a little bit, and it handles exception quite well. It will print out the error message, and try to carry on until it's fatal, like an auto try-catch. This means the user can almost always click the save button when they notice something is wrong, and analysis are less likely to be lost unless it is the save function/button crashes.

Wondering what is the common practice in the pyqt framework, other than try-catch-'em-all.

ym3141
  • 41
  • 4

0 Answers0