mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Lightly tested but seems to work fine. https://github.com/dcs-liberation/dcs_liberation/issues/1145
18 lines
449 B
Python
18 lines
449 B
Python
import logging
|
|
from collections import Iterator
|
|
from contextlib import contextmanager
|
|
from typing import Type
|
|
|
|
from PySide2.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)
|