Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not quit brutally when an exception occurs #593

Open
hydrargyrum opened this issue Aug 14, 2022 · 0 comments
Open

do not quit brutally when an exception occurs #593

hydrargyrum opened this issue Aug 14, 2022 · 0 comments

Comments

@hydrargyrum
Copy link

hydrargyrum commented Aug 14, 2022

The app may encounter exceptions from time to time, for example this debian report, this happens, this is okay. What is not cool is to quit the app when an exception occurs. Above all, it loses all unsaved data. Then, it's not very helpful to see the window suddenly disappear without any explanation.
Quitting the app (and losing data!) without explanation is worse than merely not doing the desired action without explanation. The user can usually figure out easily the action was not performed, and at least no data is lost.

PyQt has this stubborn behavior by default, I personally usually add a snippet like this to my PyQt apps:

if sys.excepthook is sys.__excepthook__:
    sys.excepthook = lambda *args: sys.__excepthook__(*args)

PyQt overrides the except hook only if it's not the default except hook. But the default except hook is fine. So this snippet tricks PyQt into thinking the except hook is not the default one, though it really is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant