Skip to content

Commit

Permalink
Merge branch 'enhance/improved-errors'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Lucas committed May 27, 2017
2 parents 1d3de98 + 368dcbe commit ea505d3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/EntryPoint/Arguments/ArgumentMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void ValidateTokensForDuplicateOptions(ArgumentModel model, List<TokenGro

if (duplicates.Any()) {
throw new DuplicateOptionException(
$"Duplicate options were entered for "
$"Duplicate options were provided for "
+ $"{string.Join("/", duplicates.Select(o => o.LongName))}");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/EntryPoint/Arguments/ArgumentModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ void ValidateContigiousOperandMapping() {

// Position should always increase by 1
} else if (diff != 1) {
throw new InvalidModelException("Non-contiguous Operand Positions. "
+ $"Operand positions should cover every position from min->max. {position} and {lastPosition} were next to each other");
throw new InvalidModelException("Missing Operand Position(s). "
+ $"Operand positions should always increment by 1 from first->last. Positions {position} and {lastPosition} leave a gap");
}

lastPosition = position;
Expand Down
5 changes: 3 additions & 2 deletions src/EntryPoint/Arguments/OptionStrategies/OptionStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ bool HasDoubleOption(Token arg, BaseOptionAttribute definition) {
object CheckValue(bool value, Type outputType, BaseOptionAttribute definition) {
if (outputType != typeof(bool)) {
throw new InvalidOperationException(
$"The type of {Cli.DASH_DOUBLE}{definition.LongName} on the ArgumentsModel, "
+ $"must be a boolean for {nameof(OptionAttribute)}");
$"The type of {Cli.DASH_DOUBLE}{definition.LongName} on the ArgumentsModel, " +
$"must be a boolean for {nameof(OptionAttribute)}. " +
$"For variable Options, you can use {nameof(OptionParameterAttribute)}");
}
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EntryPoint/CommandAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CommandAttribute : Attribute {
public CommandAttribute(string Name) {
if (Name == null || Name.Length == 0) {
throw new ArgumentException(
"You must give a Command a name");
$"A {nameof(CommandAttribute)} was not given a name");
}
this.Name = Name;
}
Expand Down
4 changes: 4 additions & 0 deletions test/Example/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"SecondaryCommand": {
"commandName": "Project",
"commandLineArgs": "Secondary \"operand one\" two three"
},
"CheckCommandDefaultError": {
"commandName": "Project",
"commandLineArgs": "one two three"
}
}
}

0 comments on commit ea505d3

Please sign in to comment.