diff src/luan/lib/rpc/RpcServer.java @ 1120:e8fc6712b468

luan Rpc uses luan.lib.rpc
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Aug 2017 23:50:52 -0600
parents 87c674f3f6b7
children
line wrap: on
line diff
--- a/src/luan/lib/rpc/RpcServer.java	Mon Aug 07 12:35:45 2017 -0600
+++ b/src/luan/lib/rpc/RpcServer.java	Mon Aug 07 23:50:52 2017 -0600
@@ -1,5 +1,6 @@
 package luan.lib.rpc;
 
+import java.io.EOFException;
 import java.net.Socket;
 import java.util.List;
 import java.util.ArrayList;
@@ -16,10 +17,16 @@
 	public RpcCall read()
 		throws RpcError
 	{
-		List list = readJson();
-		String cmd = (String)list.remove(0);
-		Object[] args = list.toArray();
-		return new RpcCall(inBinary,lenBinary,cmd,args);
+		try {
+			List list = readJson();
+			String cmd = (String)list.remove(0);
+			Object[] args = list.toArray();
+			return new RpcCall(inBinary,lenBinary,cmd,args);
+		} catch(RpcError e) {
+			if( !readSome && e.getCause() instanceof EOFException )
+				return null;
+			throw e;
+		}
 	}
 
 	public void write(RpcResult result)
@@ -38,6 +45,7 @@
 	{
 		List list = new ArrayList();
 		list.add(false);
+		list.add(ex.getMessage());
 		for( Object val : ex.values ) {
 			list.add(val);
 		}