Skip to content

added list of valid actions #127108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.common.io.stream.StreamOutput;

import java.io.IOException;
import java.util.List;

/**
* An exception indicating that a transport action was not found.
Expand All @@ -22,24 +23,42 @@
public class ActionNotFoundTransportException extends TransportException {

private final String action;
private final List<String> availableActions;

public ActionNotFoundTransportException(StreamInput in) throws IOException {
super(in);
action = in.readOptionalString();
availableActions = (List<String>) in.readOptionalStreamable();
}

public ActionNotFoundTransportException(String action) {
super("No handler for action [" + action + "]");
this.action = action;
this.availableActions = availableActions;
}

@Override
protected void writeTo(StreamOutput out, Writer<Throwable> nestedExceptionsWriter) throws IOException {
super.writeTo(out, nestedExceptionsWriter);
out.writeOptionalString(action);
out.writeOptionalStreamable(availableActions);
}

public String action() {
return this.action;
}

public List<String> getAvailableActions() {
return this.availableActions;
}

@Override
public String getMessage() {
String baseMessage = super.getMessage();
if (availableActions != null && !availableActions.isEmpty()) {
return baseMessage + "\nValid actions are: " + String.join(", ", availableActions);
} else {
return baseMessage;
}
}
}