All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codemonkey.swiftsocketclient.ServerMessageToClientInvalid Maven / Gradle / Ivy

package org.codemonkey.swiftsocketclient;

/**
 * Wrapper class of which instances substitute bad client-to-server messages. Created when decoding a message datagram failed.
 * 

* The error is communicated when the message is being executed by the server, but does not throw an exception. * * @see ServerHandler#createDecodedExecutableResponse(String) * @author Benny Bottema * @since 1.0 */ class ServerMessageToClientInvalid implements ServerMessageToClient { private String message = ""; private final Exception failureCause; public ServerMessageToClientInvalid(final ServerContext serverContext, final Exception failureCause) { this.failureCause = failureCause; } /** * {@inheritDoc} */ @Override public void decode(final String message) { this.message = message; } /** * Throws a {@link UnknownMessageException} with the current ServerMessageToClientInvalid instance. */ @Override public void execute(final Object server) throws UnknownMessageException { throw new UnknownMessageException(message, failureCause); } }