Skip to content
This repository was archived by the owner on Aug 31, 2025. It is now read-only.
Discussion options

You must be logged in to vote

You can use the sys.excepthook Python feature to capture uncaught exceptions:
https://docs.python.org/3/library/sys.html#sys.excepthook

You can see how it was implemented in Mu here:

mu/mu/app.py

Lines 168 to 198 in 0596a52

def excepthook(*exc_args):
"""
Log exception and exit cleanly.
"""
logging.error("Unrecoverable error", exc_info=(exc_args))
if exc_args[0] != KeyboardInterrupt:
try:
log_file = base64.standard_b64encode(LOG_FILE.encode("utf-8"))
error = base64.standard_b64encode(
"".join(traceback.format_exception(*exc_args)).encode("utf-8")
)[-1800:]
p = platform.uname()
params = {
"v": __version__, # version

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Tinkering-Townsperson
Comment options

Answer selected by Tinkering-Townsperson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants