Catch exception when displaying raw tags
This commit is contained in:
parent
6da177471b
commit
f7f4e41c95
@ -20,6 +20,7 @@ import logging
|
||||
from PyQt5 import QtCore, QtWidgets, uic
|
||||
|
||||
from comictaggerlib.settings import ComicTaggerSettings
|
||||
from comictaggerlib.ui import qtutils
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -41,6 +42,9 @@ class LogWindow(QtWidgets.QDialog):
|
||||
def set_text(self, text):
|
||||
try:
|
||||
text = text.decode()
|
||||
except:
|
||||
self.textEdit.setPlainText(text)
|
||||
except AttributeError:
|
||||
pass
|
||||
self.textEdit.setPlainText(text)
|
||||
except Exception as e:
|
||||
logger.exception("Displaying raw tags failed")
|
||||
qtutils.qt_error("Displaying raw tags failed:", e)
|
||||
|
@ -2,13 +2,14 @@
|
||||
|
||||
import io
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from comictaggerlib.settings import ComicTaggerSettings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from PyQt5 import QtGui
|
||||
from PyQt5 import QtGui, QtWidgets
|
||||
|
||||
qt_available = True
|
||||
except ImportError:
|
||||
@ -74,3 +75,10 @@ if qt_available:
|
||||
if not success:
|
||||
img.load(ComicTaggerSettings.get_graphic("nocover.png"))
|
||||
return img
|
||||
|
||||
def qt_error(msg: str, e: Exception = None):
|
||||
trace = ""
|
||||
if e:
|
||||
trace = "\n".join(traceback.format_exception(type(e), e, e.__traceback__))
|
||||
|
||||
QtWidgets.QMessageBox.critical(QtWidgets.QMainWindow(), "Error", msg + trace)
|
||||
|
Loading…
Reference in New Issue
Block a user