Skip to content
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

expose LocationParseException #70

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public final class LocationParser<C> implements ArgumentParser<C, Location>, Blo
)
);
}

final CommandInput originalInput = commandInput.copy();
final LocationCoordinate[] coordinates = new LocationCoordinate[3];
for (int i = 0; i < 3; i++) {
if (commandInput.peekString().isEmpty()) {
Expand Down Expand Up @@ -147,7 +147,7 @@ public final class LocationParser<C> implements ArgumentParser<C, Location>, Blo
new LocationParseException(
commandContext,
LocationParseException.FailureReason.MIXED_LOCAL_ABSOLUTE,
""
originalInput.remainingInput()
)
);
}
Expand Down Expand Up @@ -252,10 +252,19 @@ private static float toRadians(final float degrees) {
}


static class LocationParseException extends ParserException {
public static final class LocationParseException extends ParserException {

private final String input;
private final FailureReason reason;

protected LocationParseException(
/**
* Construct a new LocationParseException
*
* @param context Command context
* @param reason Failure reason
* @param input Input
*/
public LocationParseException(
final @NonNull CommandContext<?> context,
final @NonNull FailureReason reason,
final @NonNull String input
Expand All @@ -266,6 +275,26 @@ protected LocationParseException(
reason.caption(),
CaptionVariable.of("input", input)
);
this.input = input;
this.reason = reason;
}

/**
* Get the supplied input
*
* @return String value
*/
public @NonNull String input() {
return this.input;
}

/**
* Get the failure reason
*
* @return Failure reason
*/
public @NonNull FailureReason reason() {
return this.reason;
}


Expand Down