Skip to content

Commit

Permalink
expose failure reason when flag parsing fails (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
derklaro authored and jpenilla committed Aug 26, 2022
1 parent 4343c8e commit 7146448
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Core: Expose failure reason when flag parsing fails ([#380](https://github.com/Incendo/cloud/pull/380))

## [1.7.1]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ public static final class FlagParseException extends ParserException {

private static final long serialVersionUID = -7725389394142868549L;
private final String input;
private final FailureReason failureReason;

/**
* Construct a new flag parse exception
Expand All @@ -504,6 +505,7 @@ public FlagParseException(
CaptionVariable.of("flag", input)
);
this.input = input;
this.failureReason = failureReason;
}

/**
Expand All @@ -514,6 +516,17 @@ public FlagParseException(
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;
}
}


Expand Down

0 comments on commit 7146448

Please sign in to comment.