adding IDLException class. throwing IDLException on parser errors
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 2 Aug 2007 15:12:02 +0000 (15:12 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 2 Aug 2007 15:12:02 +0000 (15:12 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@7619 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/java/org/open_ils/idl/IDLException.java [new file with mode: 0644]
Open-ILS/src/java/org/open_ils/idl/IDLParser.java

diff --git a/Open-ILS/src/java/org/open_ils/idl/IDLException.java b/Open-ILS/src/java/org/open_ils/idl/IDLException.java
new file mode 100644 (file)
index 0000000..1b84d24
--- /dev/null
@@ -0,0 +1,10 @@
+package org.open_ils.idl;
+
+public class IDLException extends Exception {
+    public IDLException(String info) {
+        super(info);
+    }
+    public IDLException(String info, Throwable cause) {
+        super(info, cause);
+    }
+}
index 19b14d4..942bf5a 100644 (file)
@@ -50,7 +50,7 @@ public class IDLParser {
     /**
     * Parses the IDL XML
     */
-    public void parse() throws IOException {
+    public void parse() throws IOException, IDLException {
     
         try {
             XMLInputFactory factory = XMLInputFactory.newInstance();
@@ -85,7 +85,7 @@ public class IDLParser {
             }
 
         } catch(javax.xml.stream.XMLStreamException se) {
-            /* throw local exception */
+            throw new IDLException("Error parsing IDL XML", se);
         }
    }
 
@@ -129,7 +129,7 @@ public class IDLParser {
         }
     }
 
-    public void handleEndElement(XMLStreamReader reader) {
+    public void handleEndElement(XMLStreamReader reader) throws IDLException {
 
         if(!OILS_NS_BASE.equals(reader.getNamespaceURI())) return;
         String localpart = reader.getLocalName();
@@ -145,7 +145,13 @@ public class IDLParser {
             for(Iterator itr = fields.keySet().iterator(); itr.hasNext(); ) {
                 String key = (String) itr.next();
                 IDLField field = (IDLField) fields.get(key);
-                fieldNames[ field.getArrayPos() ] = field.getName();
+                try {
+                    fieldNames[ field.getArrayPos() ] = field.getName();
+                } catch(ArrayIndexOutOfBoundsException E) {
+                    String msg = "class="+current.getIDLClass()+";field="+key+
+                        ";fieldcount="+fields.size()+";currentpos="+field.getArrayPos();
+                    throw new IDLException(msg, E);
+                }
             }
 
             OSRFRegistry.registerObject(