diff src/luan/modules/http/LuanHandler.java @ 1077:ca968ef1747a

better handling of BindException
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 10 Nov 2016 20:36:54 -0700
parents e2a446c5c7c4
children 0d884377e923
line wrap: on
line diff
--- 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());
+		}
+	}
+
 }