]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/Spd.java
Update GlobalData, SPD, SurfaceAreaQuery to using EdkException.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / Spd.java
index cfb5dc1f875e2dc7c18f89fb9b62ba29e8dc4bc8..965e8ef499233ba5c81a41c7051b56d82635af52 100644 (file)
 package org.tianocore.build.global;\r
 \r
 import java.io.File;\r
+import java.io.IOException;\r
 import java.util.HashMap;\r
 import java.util.Iterator;\r
 import java.util.Map;\r
 import java.util.Set;\r
 \r
-import org.apache.tools.ant.BuildException;\r
+import org.apache.xmlbeans.XmlException;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
+import org.tianocore.common.exception.EdkException;\r
 \r
 /**\r
  \r
  This class is to generate a global table for the content of spd file.\r
  \r
- **/\r
+**/\r
 public class Spd {\r
     ///\r
     ///\r
@@ -88,12 +90,12 @@ public class Spd {
      \r
      This function mainly initialize some member variables. \r
     **/\r
-    Spd(File packageFile) throws BuildException {\r
+    Spd(File packageFile) throws EdkException {\r
         //\r
         // If specified package file not exists\r
         //\r
         if ( ! packageFile.exists()) {\r
-            throw new BuildException("Package file [" + packageFile.getPath() + "] does not exist!");\r
+            throw new EdkException("Package file [" + packageFile.getPath() + "] does not exist!");\r
         }\r
         try {\r
             XmlObject spdDoc = XmlObject.Factory.parse(packageFile);\r
@@ -101,15 +103,15 @@ public class Spd {
             // Verify SPD file, if is invalid, throw Exception\r
             //\r
             if (! spdDoc.validate()) {\r
-                throw new BuildException("Package Surface Area file [" + packageFile.getPath() + "] format is invalid!");\r
+                throw new EdkException("Package Surface Area file [" + packageFile.getPath() + "] format is invalid!");\r
             }\r
+            //\r
             // We can change Map to XmlObject\r
+            //\r
             Map<String, XmlObject> spdDocMap = new HashMap<String, XmlObject>();\r
             spdDocMap.put("PackageSurfaceArea", spdDoc);\r
             SurfaceAreaQuery saq = new SurfaceAreaQuery(spdDocMap);\r
-            //\r
-            //\r
-            //\r
+\r
             packageId = saq.getSpdHeader();\r
             packageId.setSpdFile(packageFile);\r
             \r
@@ -127,7 +129,7 @@ public class Spd {
                 moduleId.setPackage(packageId);\r
                 moduleId.setMsaFile(msaFile);\r
                 if (msaInfo.containsKey(moduleId)) {\r
-                    throw new BuildException("Found two modules with the same GUID and Version in package " + packageId + ".\nThey are  module [" + msaInfo.get(moduleId) + "] and MSA file [" + msaFile + "]!");\r
+                    throw new EdkException("Found two modules with the same GUID and Version in package " + packageId + ".\nThey are  module [" + msaInfo.get(moduleId) + "] and MSA file [" + msaFile + "]!");\r
                 }\r
                 msaInfo.put(moduleId, msaFile);\r
             }\r
@@ -196,10 +198,14 @@ public class Spd {
                 }\r
                 libClassHeaderList.put(libraryClassName, headerFiles);\r
             }\r
-        }\r
-        catch (Exception e) {\r
-            throw new BuildException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n"\r
-                                     + e.getMessage());\r
+        } catch (IOException ex) {\r
+            EdkException edkException = new EdkException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n" + ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
+        } catch (XmlException ex) {\r
+            EdkException edkException = new EdkException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n" + ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
         }\r
     }\r
 \r