Skip to content

Commit 7146448

Browse files
derklarojpenilla
authored andcommitted
expose failure reason when flag parsing fails (#380)
1 parent 4343c8e commit 7146448

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Added
10+
- Core: Expose failure reason when flag parsing fails ([#380](https://github.com/Incendo/cloud/pull/380))
11+
912
## [1.7.1]
1013

1114
### Added

cloud-core/src/main/java/cloud/commandframework/arguments/compound/FlagArgument.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ public static final class FlagParseException extends ParserException {
483483

484484
private static final long serialVersionUID = -7725389394142868549L;
485485
private final String input;
486+
private final FailureReason failureReason;
486487

487488
/**
488489
* Construct a new flag parse exception
@@ -504,6 +505,7 @@ public FlagParseException(
504505
CaptionVariable.of("flag", input)
505506
);
506507
this.input = input;
508+
this.failureReason = failureReason;
507509
}
508510

509511
/**
@@ -514,6 +516,17 @@ public FlagParseException(
514516
public String getInput() {
515517
return this.input;
516518
}
519+
520+
/**
521+
* Returns the reason why the flag parsing failed.
522+
*
523+
* @return the failure reason
524+
* @since 1.8.0
525+
*/
526+
@API(status = API.Status.STABLE, since = "1.8.0")
527+
public @NonNull FailureReason failureReason() {
528+
return this.failureReason;
529+
}
517530
}
518531

519532

0 commit comments

Comments
 (0)