getopt.net
A port of getopt in pure C#.
Loading...
Searching...
No Matches
ParseException.cs
Go to the documentation of this file.
1using System;
2
3namespace getopt.net {
4
14 public class ParseException: Exception {
15
20 public ParseException(string msg): this(null, msg) { }
21
27 public ParseException(string? optString, string msg): base(msg) {
28 Option = optString;
29 }
30
32 public override string ToString() {
33 if (string.IsNullOrEmpty(Option)) {
34 return base.ToString();
35 }
36 return $"Error occurred while parsing { Option }: { Message }";
37 }
38
42 public string? Option { get; set; }
43 }
44}
45
Generic exception class that is thrown when the parser is not configured to ignore errors.
override string ToString()
ParseException(string? optString, string msg)
Specialsied exception constructor; accepts the option causing the error and an accompanying message.
ParseException(string msg)
Generic exception constructor; only accepts the error message.
Represents a single long option for getopt.
Definition Option.cs:8