Add exception handling for parsing error within the preset route.
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 21 Jun 2010 13:18:35 +0000 (13:18 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 21 Jun 2010 13:18:35 +0000 (13:18 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3927 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BProject.py
wizard/BProjectPresets.py

index 366e9a7525058b504d94c60c69b859df4f9b598b..1e477c688aa01ba041771f4d6c51275f98528021 100644 (file)
@@ -245,7 +245,7 @@ class BProject(object):
                 try:
                     to_be_parsed, module_dict = loadModuleDefinition(comment_list[0])
                 except ParseError, err:
-                    raise DefineException.ModuleDefineException(path, err.line_number, err.line)
+                    raise DefineException.ModuleDefineException(os.path.join(path, filename), err.line_number, err.line)
                 for module, information in module_dict.items():
                     if "depends" not in information:
                         information["depends"] = ()
@@ -283,7 +283,7 @@ class BProject(object):
                         list_dict = loadDefineLists(comment_list[1:])
                         list_info_dict.update(list_dict)
                     except ParseError, err:
-                        raise DefineException.EnumDefineException(path, err.line_number, err.line)
+                        raise DefineException.EnumDefineException(os.path.join(path, filename), err.line_number, err.line)
         for tag in self.infos["CPU_INFOS"]["CPU_TAGS"]:
             for filename, path in self.findDefinitions("*_" + tag + ".h"):
                 comment_list = getCommentList(open(path + "/" + filename, "r").read())
index 9afed4f4328ea37ccefb71f2c6a967ba45623f45..2b5dd6735acb89921aaf0a730b8afecc70eaa02e 100644 (file)
@@ -45,6 +45,8 @@ from BWizardPage import BWizardPage
 from BCreationPage import BCreationPage
 from BToolchainPage import BToolchainPage
 
+from DefineException import ModuleDefineException
+
 from bertos_utils import _cmp
 from toolchain_manager import ToolchainManager
 
@@ -121,7 +123,10 @@ class BProjectPresets(BWizardPage):
         preset_path = self.selected_path
         try:
             QApplication.instance().setOverrideCursor(Qt.WaitCursor)
-            self.project.loadProjectFromPreset(preset_path)
+            try:
+                self.project.loadProjectFromPreset(preset_path)
+            except ModuleDefineException, e:
+                self.exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
             self.setProjectInfo("PRESET_LOADED", True)
         finally:
             QApplication.instance().restoreOverrideCursor()