getopt.net
A port of getopt in pure C#.
Loading...
Searching...
No Matches
getopt.net.ParseException Class Reference

Generic exception class that is thrown when the parser is not configured to ignore errors. More...

Inheritance diagram for getopt.net.ParseException:

Public Member Functions

 ParseException (string msg)
 Generic exception constructor; only accepts the error message.
 
 ParseException (string? optString, string msg)
 Specialsied exception constructor; accepts the option causing the error and an accompanying message.
 
override string ToString ()
 

Properties

string? Option [get, set]
 The option that caused the exception.
 

Detailed Description

Generic exception class that is thrown when the parser is not configured to ignore errors.

This exception may be thrown whenever one of the following options is disabled:

  • GetOpt.IgnoreEmptyAppArgs
  • GetOpt.IgnoreEmptyOptions
  • GetOpt.IgnoreInvalidOptions
  • GetOpt.IgnoreMissingArgument

Definition at line 14 of file ParseException.cs.

Constructor & Destructor Documentation

◆ ParseException() [1/2]

getopt.net.ParseException.ParseException ( string  msg)
inline

Generic exception constructor; only accepts the error message.

Parameters
msgA brief description of the error.

Definition at line 20 of file ParseException.cs.

20: this(null, msg) { }

◆ ParseException() [2/2]

getopt.net.ParseException.ParseException ( string?  optString,
string  msg 
)
inline

Specialsied exception constructor; accepts the option causing the error and an accompanying message.

Parameters
optStringThe option that caused the exception.
msgA brief description of the error.

Definition at line 27 of file ParseException.cs.

27 : base(msg) {
28 Option = optString;
29 }
string? Option
The option that caused the exception.

Member Function Documentation

◆ ToString()

override string getopt.net.ParseException.ToString ( )
inline

Definition at line 32 of file ParseException.cs.

32 {
33 if (string.IsNullOrEmpty(Option)) {
34 return base.ToString();
35 }
36 return $"Error occurred while parsing { Option }: { Message }";
37 }

Property Documentation

◆ Option

string? getopt.net.ParseException.Option
getset

The option that caused the exception.

Definition at line 42 of file ParseException.cs.

42{ get; set; }

The documentation for this class was generated from the following file: