expose failure reason when flag parsing fails (#380)

This commit is contained in:
Pasqual Koschmieder 2022-06-25 09:10:03 +02:00 committed by Jason
parent 36787198f7
commit 09a66cef95
2 changed files with 16 additions and 0 deletions

View file

@ -483,6 +483,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
private static final long serialVersionUID = -7725389394142868549L;
private final String input;
private final FailureReason failureReason;
/**
* Construct a new flag parse exception
@ -504,6 +505,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
CaptionVariable.of("flag", input)
);
this.input = input;
this.failureReason = failureReason;
}
/**
@ -514,6 +516,17 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
public String getInput() {
return this.input;
}
/**
* Returns the reason why the flag parsing failed.
*
* @return the failure reason
* @since 1.8.0
*/
@API(status = API.Status.STABLE, since = "1.8.0")
public @NonNull FailureReason failureReason() {
return this.failureReason;
}
}