[GRASS-SVN] r30469 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 4 15:18:00 EST 2008


Author: martinl
Date: 2008-03-04 15:18:00 -0500 (Tue, 04 Mar 2008)
New Revision: 30469

Modified:
   grass/trunk/gui/wxpython/gui_modules/gcmd.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: error dialog if reading workspace file failed

Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-03-04 17:53:39 UTC (rev 30468)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-03-04 20:18:00 UTC (rev 30469)
@@ -63,6 +63,12 @@
 
         return ''
 
+class GStdError(GException):
+    """Generic exception"""
+
+    def __init__(self, message, title=_("Error"), parent=None):
+        GException.__init__(self, message, title=title, parent=parent)
+
 class CmdError(GException):
     """Exception used for GRASS commands.
 

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-03-04 17:53:39 UTC (rev 30468)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-03-04 20:18:00 UTC (rev 30469)
@@ -568,7 +568,13 @@
 
             # sax
             grcXml = ProcessGrcXml()
-            xml.sax.parseString(fileStream, grcXml)
+            
+            try:
+                xml.sax.parseString(fileStream, grcXml)
+            except xml.sax.SAXParseException, err:
+                raise gcmd.GStdError(_("Reading workspace file <%s> failed.") % filename + \
+                                         "\n\n%s" % err,
+                                     parent=self)
 
             busy = wx.BusyInfo(message=_("Please wait, loading map layers into layer tree..."),
                                parent=self)
@@ -599,7 +605,10 @@
                                                      filename, os.linesep, err),
                           caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
             return False
-
+        except gcmd.GStdError, e:
+            print e
+            return False
+                               
         return True
 
     def OnWorkspaceLoad(self, event=None):



More information about the grass-commit mailing list