libroar/RoarCanvasCommandsFile.py:_import(): handle FileNotFoundError exception.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-11 13:53:48 +02:00
parent 6109e9b38c
commit e30628f28d

View File

@ -22,7 +22,9 @@ import io, os, wx
class RoarCanvasCommandsFile():
# {{{ _import(self, f, newDirty, pathName)
def _import(self, f, newDirty, pathName):
rc = False
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
try:
rc, error, newMap, newPathName, newSize = f(pathName)
if rc:
self.parentCanvas.dirty = newDirty
@ -31,7 +33,9 @@ class RoarCanvasCommandsFile():
self.update(dirty=self.parentCanvas.dirty, pathName=self.canvasPathName, undoLevel=-1)
self.parentCanvas.canvas.journal.resetCursor()
self.parentCanvas.canvas.journal.resetUndo()
else:
except FileNotFoundError as e:
rc, error, newMap, newPathName, newSize = False, str(e), None, None, None
if not rc:
with wx.MessageDialog(self.parentCanvas, "Error: {}".format(error), "", wx.OK | wx.OK_DEFAULT) as dialog:
dialogChoice = dialog.ShowModal()
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))