throw an exception when an action is not found

This commit is contained in:
kimchy 2010-05-26 09:16:10 +03:00
parent 32e4c405de
commit 9a49629d17
2 changed files with 13 additions and 4 deletions

View File

@ -20,11 +20,20 @@
package org.elasticsearch.transport;
/**
* @author kimchy (Shay Banon)
* An exception indicating that a transport action was not found.
*
* @author kimchy (shay.banon)
*/
public class ActionNotFoundTransportException extends TransportException {
public ActionNotFoundTransportException(String message) {
super(message);
private final String action;
public ActionNotFoundTransportException(String action) {
super("No handler for action [" + action + "]");
this.action = action;
}
public String action() {
return this.action;
}
}

View File

@ -164,7 +164,7 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler {
try {
final TransportRequestHandler handler = transportServiceAdapter.handler(action);
if (handler == null) {
logger.warn("No handler found for action [{}]", action);
throw new ActionNotFoundTransportException(action);
}
final Streamable streamable = handler.newInstance();
streamable.readFrom(buffer);