Move error reporting out of the NWDoc class
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user