public class PortInUseException extends WebServerException
PortInUseException is thrown when a web server fails to start due to a port
already being in use.| Constructor and Description |
|---|
PortInUseException(int port)
Creates a new port in use exception for the given
port. |
PortInUseException(int port,
java.lang.Throwable cause)
Creates a new port in use exception for the given
port. |
| Modifier and Type | Method and Description |
|---|---|
int |
getPort()
Returns the port that was in use.
|
static <E extends java.lang.Exception> |
ifCausedBy(java.lang.Exception ex,
java.lang.Class<E> causedBy,
java.util.function.Consumer<E> action)
Perform an action if the given exception was caused by a specific exception type.
|
static void |
ifPortBindingException(java.lang.Exception ex,
java.util.function.Consumer<java.net.BindException> action)
Perform an action if the given exception was caused by a "port in use"
BindException. |
static void |
throwIfPortBindingException(java.lang.Exception ex,
java.util.function.IntSupplier port)
Throw a
PortInUseException if the given exception was caused by a "port in
use" BindException. |
public PortInUseException(int port)
port.port - the port that was in usepublic PortInUseException(int port,
java.lang.Throwable cause)
port.port - the port that was in usecause - the cause of the exceptionpublic int getPort()
public static void throwIfPortBindingException(java.lang.Exception ex,
java.util.function.IntSupplier port)
PortInUseException if the given exception was caused by a "port in
use" BindException.ex - the source exceptionport - a suppler used to provide the portpublic static void ifPortBindingException(java.lang.Exception ex,
java.util.function.Consumer<java.net.BindException> action)
BindException.ex - the source exceptionaction - the action to performpublic static <E extends java.lang.Exception> void ifCausedBy(java.lang.Exception ex,
java.lang.Class<E> causedBy,
java.util.function.Consumer<E> action)
E - the cause exception typeex - the source exceptioncausedBy - the required cause typeaction - the action to perform