1 /++ 2 $(H2 The Error Types for Cmdline) 3 Authors: 笑愚(xiaoyu) 4 +/ 5 module cmdline.error; 6 7 /// the error occurs when configuring the cmd-line or parsing the command line in debug mode 8 class CMDLineError : Error { 9 enum string name = typeof(this).stringof; 10 11 string code; 12 ubyte exitCode; 13 14 this(string msg = "", ubyte exitCode = 1, string code = "", Throwable nextInChain = null) pure nothrow @nogc @safe { 15 super(msg, nextInChain); 16 this.exitCode = exitCode; 17 this.code = code; 18 } 19 } 20 21 /// the error about argument. 22 /// the error would be caputured then throw `CMDLineError` when parsing the command line 23 /// or not captured when configuring argument 24 class InvalidArgumentError : CMDLineError { 25 enum string name = typeof(this).stringof; 26 27 this(string msg = "", string code = "") { 28 super(msg, 1, code); 29 } 30 } 31 32 /// the error about option 33 /// the error would be captured the throw `CMDLineError` when parsing the command line 34 /// or not captured when configuring option 35 class InvalidOptionError : CMDLineError { 36 enum string name = typeof(this).stringof; 37 38 this(string msg = "", string code = "") { 39 super(msg, 1, code); 40 } 41 } 42 43 /// deprecated 44 class InvalidFlagError : CMDLineError { 45 enum string name = typeof(this).stringof; 46 47 this(string msg = "") { 48 super(msg, 1, "CMDLine."~name); 49 } 50 } 51 52 /// deprecated 53 class ImplyOptionError : CMDLineError { 54 enum string name = typeof(this).stringof; 55 56 this(string msg = "") { 57 super(msg, 1, "CMDLine."~name); 58 } 59 } 60 61 /// deprecated 62 class OptionFlagsError : CMDLineError { 63 enum string name = typeof(this).stringof; 64 65 this(string msg = "") { 66 super(msg, 1, "CMDLine."~name); 67 } 68 } 69 70 /// deprecated 71 class OptionMemberFnCallError : CMDLineError { 72 enum string name = typeof(this).stringof; 73 74 this(string msg = "") { 75 super(msg, 1, "CMDLine."~name); 76 } 77 }