Move error reporting out of the NWDoc class

This commit is contained in:
Veronica K. B. Olsen
2021-04-25 23:21:51 +02:00
parent 470daf0036
commit 0eb09a2136
5 changed files with 50 additions and 19 deletions
+9 -1
View File
@@ -111,6 +111,11 @@ class GuiDocMerge(QDialog):
for tHandle in finalOrder:
inDoc = NWDoc(self.theProject, tHandle)
docText = inDoc.readDocument().rstrip("\n")
docErr = inDoc.getError()
if docText is None and docErr:
self.makeAlert(
[self.tr("Failed to open document file."), docErr], nwAlert.ERROR
)
if docText:
theText += docText+"\n\n"
@@ -132,7 +137,10 @@ class GuiDocMerge(QDialog):
newItem.setStatus(srcItem.itemStatus)
outDoc = NWDoc(self.theProject, nHandle)
outDoc.writeDocument(theText)
if not outDoc.writeDocument(theText):
self.theParent.makeAlert(
[self.tr("Could not save document."), outDoc.getError()], nwAlert.ERROR
)
self.theParent.treeView.revealNewTreeItem(nHandle)
self.theParent.openDocument(nHandle, doScroll=True)
+11 -1
View File
@@ -129,6 +129,13 @@ class GuiDocSplit(QDialog):
inDoc = NWDoc(self.theProject, self.sourceItem)
theText = inDoc.readDocument()
docErr = inDoc.getError()
if theText is None and docErr:
self.theParent.makeAlert(
[self.tr("Failed to open document file."), docErr], nwAlert.ERROR
)
if theText is None:
theText = ""
@@ -219,7 +226,10 @@ class GuiDocSplit(QDialog):
theText = theText.rstrip("\n") + "\n\n"
outDoc = NWDoc(self.theProject, nHandle)
outDoc.writeDocument(theText)
if not outDoc.writeDocument(theText):
self.theParent.makeAlert(
[self.tr("Could not save document."), outDoc.getError()], nwAlert.ERROR
)
self.theParent.treeView.revealNewTreeItem(nHandle)