changeset 1077:ca968ef1747a

better handling of BindException
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 10 Nov 2016 20:36:54 -0700
parents 66ff32660031
children 99f1c125926f
files src/luan/modules/http/LuanHandler.java src/luan/modules/http/Server.luan
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
diff -r 66ff32660031 -r ca968ef1747a src/luan/modules/http/LuanHandler.java
--- a/src/luan/modules/http/LuanHandler.java	Thu Nov 10 20:06:33 2016 -0700
+++ b/src/luan/modules/http/LuanHandler.java	Thu Nov 10 20:36:54 2016 -0700
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.lang.reflect.Method;
+import java.net.BindException;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.servlet.http.HttpServletRequest;
@@ -9,6 +10,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.handler.AbstractHandler;
 import luan.Luan;
 import luan.LuanState;
@@ -158,4 +160,12 @@
 		}
 	}
 
+	public static void start(Server server) throws Exception {
+		try {
+			server.start();
+		} catch(BindException e) {
+			throw new LuanException(e.toString());
+		}
+	}
+
 }
diff -r 66ff32660031 -r ca968ef1747a src/luan/modules/http/Server.luan
--- a/src/luan/modules/http/Server.luan	Thu Nov 10 20:06:33 2016 -0700
+++ b/src/luan/modules/http/Server.luan	Thu Nov 10 20:36:54 2016 -0700
@@ -97,7 +97,7 @@
 end
 
 function M.start()
-	M.server.start()
+	LuanHandler.start(M.server)
 end
 
 function M.start_rpc()