From 93b3b785c79261b31001a027231a8abcefae0a67 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 2 Aug 2007 15:12:02 +0000 Subject: [PATCH] adding IDLException class. throwing IDLException on parser errors 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 | 10 ++++++++++ Open-ILS/src/java/org/open_ils/idl/IDLParser.java | 14 ++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 Open-ILS/src/java/org/open_ils/idl/IDLException.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 index 0000000000..1b84d2481b --- /dev/null +++ b/Open-ILS/src/java/org/open_ils/idl/IDLException.java @@ -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); + } +} diff --git a/Open-ILS/src/java/org/open_ils/idl/IDLParser.java b/Open-ILS/src/java/org/open_ils/idl/IDLParser.java index 19b14d4842..942bf5aa6c 100644 --- a/Open-ILS/src/java/org/open_ils/idl/IDLParser.java +++ b/Open-ILS/src/java/org/open_ils/idl/IDLParser.java @@ -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( -- 2.11.0