You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given issues like #2199 , where failure to catch all relevant exceptions in the killswitch code can lead to the program crashing on startup, looking to the user like it's not working at all, it would be an improvement to User Experience (UX), not to mention gathering bug reports, to have a top level try/except to catch all unhandled exceptions.
There's already a try/except around the tkinter root.mainloop() call, in order to catch KeyboardInterrupt and attempt a clean shutdown. This is where a catch-all except would go.
The body of this accept should:
Log the exception, so there's some useful information to go on about the cause/source.
Pop up a blocking (the program is in a BAD state and going DOWN, and you're outside of the tkinter mainloop now anyway), alert to the user about having encountered a fatal bug, and to please go make a bug report. Given being outside the tkinter mainloop you're going to have to create a wholly new top-level window for this. Something basic with the message and a single 'OK' button to close it.
Close the program with no attempt to clean up anything. There's no telling what bad state the program might be in.
Importantly such a general exception catch will not stop any core or plugin code from catching and handling its own exceptions. It's just the place of last resort to handle any errors.
There are some choices for the exact nature of this general exception catch:
except: - completely bare, which catches literally every exception, including KeyboardInterrup, SystemExit and some others.
except Exception as e: - Will not catch those "very top level, system" exceptions, and is likely the behaviour you want. Also means you can do something with e if needs be (but remember you can just logger.exception(...), no need to reference it).
except BaseException as e: - will likely give much the same behaviour as with Exception.
To hammer it home, the point of this is:
Better User Experience - not having the program just disappear or look like it never started.
Encourage users who experience such a crash to make a bug report so the culprit code can be improved.
The text was updated successfully, but these errors were encountered:
Given issues like #2199 , where failure to catch all relevant exceptions in the killswitch code can lead to the program crashing on startup, looking to the user like it's not working at all, it would be an improvement to User Experience (UX), not to mention gathering bug reports, to have a top level try/except to catch all unhandled exceptions.
root.mainloop()
call, in order to catchKeyboardInterrupt
and attempt a clean shutdown. This is where a catch-allexcept
would go.There are some choices for the exact nature of this general exception catch:
except:
- completely bare, which catches literally every exception, includingKeyboardInterrup
,SystemExit
and some others.except Exception as e:
- Will not catch those "very top level, system" exceptions, and is likely the behaviour you want. Also means you can do something withe
if needs be (but remember you can justlogger.exception(...)
, no need to reference it).except BaseException as e:
- will likely give much the same behaviour as withException
.To hammer it home, the point of this is:
The text was updated successfully, but these errors were encountered: