Exception for loading from file caught too

master
Jaka Perovšek 2024-10-05 12:21:52 +02:00
parent ed9834ea37
commit e489737f5f
1 changed files with 8 additions and 3 deletions

View File

@ -348,10 +348,15 @@ class ValidationWidget(QWidget):
self.load_tapes_from_file()
def load_tapes_from_file(self):
with open("./source/tapes.yaml", encoding="utf-8") as fp:
tapes = yaml.safe_load(fp)
try:
with open("./source/tapes.yaml", encoding="utf-8") as fp:
tapes = yaml.safe_load(fp)
self.load_tapes(tapes)
except yaml.scanner.ScannerError as e:
dlg = DebugDialog(f"Error applying yaml code:\n\n{str(e)}")
dlg.exec()
self.load_tapes(tapes)
def load_tapes(self, tapes):
self.tapes = tapes