diff src/luan/modules/http/LuanHandler.java @ 1004:3fa54d9d19cd

better handling of BindException
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 22 Oct 2016 23:00:57 -0600
parents 32d4b569567c
children 0d884377e923
line wrap: on
line diff
--- a/src/luan/modules/http/LuanHandler.java	Sat Oct 22 22:24:47 2016 -0600
+++ b/src/luan/modules/http/LuanHandler.java	Sat Oct 22 23:00:57 2016 -0600
@@ -2,12 +2,14 @@
 
 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.HttpServletResponse;
 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;
@@ -159,4 +161,11 @@
 		}
 	}
 
+	public static void start(Server server) throws Exception {
+		try {
+			server.start();
+		} catch(BindException e) {
+			throw new LuanException(e.toString());
+		}
+	}
 }