dcs_liberation/qt_ui/errorreporter.py
Dan Albert 306971230b Update to PySide6.
It sounds like PySide2 will not be moving to Python 3.11, so we're stuck
on 3.10 without this. Upgrading to a newer Qt also fixes some high DPI
bugs (the file browser dialog for save/load is no longer tiny on 4k).

https://github.com/pyinstaller/pyinstaller/issues/5414 previously
blocked this, but the bug appears to be fixed now.
2022-12-29 16:26:50 -08:00

18 lines
453 B
Python

import logging
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Type
from PySide6.QtWidgets import QDialog, QMessageBox
@contextmanager
def report_errors(
title: str, parent: QDialog, error_type: Type[Exception] = Exception
) -> Iterator[None]:
try:
yield
except error_type as ex:
logging.exception(title)
QMessageBox().critical(parent, title, str(ex), QMessageBox.Ok)