Put more info in ApplicationError dialog

Show it after dumping error to stderr
This commit is contained in:
Keith Edmunds 2025-03-09 16:34:53 +00:00
parent 5f9fd31dfd
commit 582803dccc

View File

@ -80,8 +80,6 @@ log = logging.getLogger(Config.LOG_NAME)
def handle_exception(exc_type, exc_value, exc_traceback):
error = str(exc_value)
if QApplication.instance() is not None:
QMessageBox.critical(None, "Application Error", error)
if issubclass(exc_type, ApplicationError):
log.error(error)
else:
@ -104,6 +102,10 @@ def handle_exception(exc_type, exc_value, exc_traceback):
"Exception (log_uncaught_exceptions) from musicmuster",
msg,
)
if QApplication.instance() is not None:
fname = os.path.split(exc_traceback.tb_frame.f_code.co_filename)[1]
msg = f"ApplicationError: {error}\nat {fname}:{exc_traceback.tb_lineno}"
QMessageBox.critical(None, "Application Error", msg)
sys.excepthook = handle_exception