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,
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 Exception> |
ifCausedBy(Exception ex,
Class<E> causedBy,
Consumer<E> action)
Perform an action if the given exception was caused by a specific exception type.
|
static void |
ifPortBindingException(Exception ex,
Consumer<BindException> action)
Perform an action if the given exception was caused by a "port in use"
BindException . |
static void |
throwIfPortBindingException(Exception ex,
IntSupplier port)
Throw a
PortInUseException if the given exception was caused by a "port in
use" BindException . |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public PortInUseException(int port)
port
.port
- the port that was in usepublic PortInUseException(int port, Throwable cause)
port
.port
- the port that was in usecause
- the cause of the exceptionpublic int getPort()
public static void throwIfPortBindingException(Exception ex, 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(Exception ex, Consumer<BindException> action)
BindException
.ex
- the source exceptionaction
- the action to performpublic static <E extends Exception> void ifCausedBy(Exception ex, Class<E> causedBy, Consumer<E> action)
E
- the cause exception typeex
- the source exceptioncausedBy
- the required cause typeaction
- the action to performCopyright © 2020 Pivotal Software, Inc.. All rights reserved.