Skip to content

Commit a77e330

Browse files
committed
Add colorized variants of the CommandLineValidationException constructor
1 parent 04cef79 commit a77e330

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

Src/Exceptions.cs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Reflection;
1+
using System.Reflection;
2+
using RT.Util;
23
using RT.Util.Consoles;
34
using RT.Util.ExtensionMethods;
45

@@ -181,14 +182,30 @@ public sealed class InvalidNumericParameterException(string fieldName, Func<int,
181182
public InvalidNumericParameterException(string fieldName, Func<int, ConsoleColoredString> helpGenerator) : this(fieldName, helpGenerator, null) { }
182183
}
183184

184-
/// <summary>
185-
/// Indicates that the arguments specified by the user on the command-line do not pass the custom validation check.</summary>
186-
/// <param name="message">
187-
/// Provide a helpful, descriptive message for the user to determine how to provide a valid command-line parameter.</param>
188-
/// <param name="helpGenerator">
189-
/// Used internally to generate the help screen; omit if throwing from a validation check.</param>
185+
/// <summary>Indicates that the arguments specified by the user on the command-line do not pass the custom validation check.</summary>
190186
[Serializable]
191-
public sealed class CommandLineValidationException(ConsoleColoredString message, Func<int, ConsoleColoredString> helpGenerator = null)
192-
: CommandLineParseException(message, helpGenerator)
187+
public sealed class CommandLineValidationException : CommandLineParseException
193188
{
189+
/// <summary>Constructor.</summary>
190+
internal CommandLineValidationException(ConsoleColoredString message, Func<int, ConsoleColoredString> helpGenerator) : base(message, helpGenerator) { }
191+
192+
/// <summary>
193+
/// Constructor.</summary>
194+
/// <param name="message">
195+
/// Provide a helpful, descriptive message for the user to determine how to provide a valid command-line parameter.</param>
196+
public CommandLineValidationException(ConsoleColoredString message) : base(message, null) { }
197+
198+
/// <summary>
199+
/// Constructor.</summary>
200+
/// <param name="message">
201+
/// Provide a helpful, descriptive message for the user to determine how to provide a valid command-line parameter.
202+
/// This message is colorized with <see cref="CommandLineParser.Colorize(RhoElement)"/>.</param>
203+
public CommandLineValidationException(RhoElement message) : base(CommandLineParser.Colorize(message), null) { }
204+
205+
/// <summary>
206+
/// Constructor.</summary>
207+
/// <param name="message">
208+
/// Provide a helpful, descriptive message for the user to determine how to provide a valid command-line parameter.
209+
/// This message is colorized with <see cref="CommandLineParser.Colorize(EggsNode)"/>.</param>
210+
public CommandLineValidationException(EggsNode message) : base(CommandLineParser.Colorize(message), null) { }
194211
}

0 commit comments

Comments
 (0)