Update of /cvsroot/monetdb/java/src/nl/cwi/monetdb/xquery/xrpc/api
In directory 
sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19545/src/nl/cwi/monetdb/xquery/xrpc/api

Modified Files:
        XRPCHTTPConnection.java XRPCMessage.java 
Log Message:
be more precise with the exceptions we throw, to make it easier to
dicide which ones should be reported to the calling peer, and which ones
not.



Index: XRPCHTTPConnection.java
===================================================================
RCS file: 
/cvsroot/monetdb/java/src/nl/cwi/monetdb/xquery/xrpc/api/XRPCHTTPConnection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- XRPCHTTPConnection.java     5 Dec 2007 17:02:00 -0000       1.1
+++ XRPCHTTPConnection.java     6 Dec 2007 18:18:48 -0000       1.2
@@ -45,7 +45,7 @@
     public static void send(BufferedWriter socketWriter,
                             String httpHeader,
                             String xrpcMessage)
-        throws Exception
+        throws IOException
     {
         socketWriter.write(httpHeader);
         socketWriter.write(xrpcMessage);
@@ -134,7 +134,7 @@
      * SOAP Fault message */
     public static StringBuffer sendReceive(String server,
                                            String request)
-        throws Exception
+        throws IOException
     {
         URL url = new URL(server);
         HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();

Index: XRPCMessage.java
===================================================================
RCS file: 
/cvsroot/monetdb/java/src/nl/cwi/monetdb/xquery/xrpc/api/XRPCMessage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- XRPCMessage.java    5 Dec 2007 17:02:00 -0000       1.1
+++ XRPCMessage.java    6 Dec 2007 18:18:48 -0000       1.2
@@ -257,13 +257,13 @@
         /* Find the start and end of the tag "Envelope" */
         start = msg.indexOf("Envelope");
         if(start < 0){
-            throw new XRPCSenderException(
+            throw new XRPCException(
                     "XRPC " + msgType + " message not well-formed:" +
                     "could not find the \"Envelope\" tag.");
         }
         end = msg.indexOf(">", (start + 8));
         if(end < 0){
-            throw new XRPCSenderException(
+            throw new XRPCException(
                     "XRPC " + msgType + " message nog well-formed: " +
                     "could not find the end of the \"Envelope\" tag.");
         }
@@ -271,13 +271,13 @@
         /* Find the end of the tag msgType */
         end = msg.indexOf(msgType, end);
         if(end < 0){
-            throw new XRPCSenderException(
+            throw new XRPCException(
                     "XRPC " + msgType + " message not well-formed:" +
                     "could not find the \"" + msgType + "\" tag.");
         }
         end = msg.indexOf(">", (end + 7));
         if(end < 0){
-            throw new XRPCSenderException(
+            throw new XRPCException(
                     "XRPC " + msgType + " message nog well-formed: " +
                     "could not find the end of the \"" +
                     msgType + "\" tag.");
@@ -297,7 +297,7 @@
                 end = str.lastIndexOf("=", start);
                 start = str.lastIndexOf("\"", end) + 1;
                 if(str.indexOf("xmlns",start) != start){
-                    throw new XRPCSenderException(
+                    throw new XRPCException(
                             "XRPC " + msgType + " message not " +
                             "well-formed: \"xmlns\" expected in a " +
                             "namespace declaration.");
@@ -308,7 +308,7 @@
             start += nsLen;
         } while(start < end);
 
-        throw new XRPCSenderException(
+        throw new XRPCException(
                 "XRPC " + msgType + " message nog well-formed: " +
                 "declaration of the namespace \"" + namespaceURI +
                 "\" not found.");
@@ -388,7 +388,7 @@
                               xrpcPrefix + ":atomic-value/text()",
                         new InputSource(new StringReader(request)));
             }
-        } catch (Exception e){
+        } catch (XPathExpressionException e){
             throw new XRPCSenderException(
                     "Failed to execute XPath query:" +
                     e.getClass().getName() +
@@ -407,11 +407,18 @@
     public static NamedNodeMap getNodeAttributes(XPath xPath,
                                                  String xmlStr,
                                                  String xPathExpr)
-        throws Exception
+        throws XRPCException
     {
         InputSource inputSource = new InputSource(new StringReader(xmlStr));
-        NodeList nodeList = (NodeList) xPath.evaluate(xPathExpr,
-                inputSource, XPathConstants.NODESET);
+        NodeList nodeList;
+        try{
+            nodeList = (NodeList) xPath.evaluate(xPathExpr, inputSource,
+                    XPathConstants.NODESET);
+        } catch (XPathExpressionException e) {
+            throw new XRPCException("Exactly 1 node is expected, " +
+                    "got XPathExpressionException instead:" +
+                    e.getMessage());
+        }
         if(nodeList.getLength() != 1){
             throw new XRPCException("Exactly 1 node is expected, got " +
                                     nodeList.getLength());
@@ -431,7 +438,7 @@
                                                 String xmlStr,
                                                 String xPathExpr,
                                                 String attrName)
-        throws Exception
+        throws XPathExpressionException
     {
         InputSource inputSource = new InputSource(new StringReader(xmlStr));
         NodeList nodeList = (NodeList) xPath.evaluate(xPathExpr,


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to