diff --git a/include/tclap/SwitchArg.h b/include/tclap/SwitchArg.h index dc4952e..3961e35 100644 --- a/include/tclap/SwitchArg.h +++ b/include/tclap/SwitchArg.h @@ -197,7 +197,15 @@ inline bool SwitchArg::processArg(int *i, std::vector& args) ret = true; if ( _alreadySet || ( !ret && combinedSwitchesMatch( args[*i] ) ) ) - throw(CmdLineParseException("Argument already set!", toString())); + { + if ( _xorSet ) + throw(CmdLineParseException( + "Mutually exclusive argument already set!", + toString())); + else + throw(CmdLineParseException("Argument already set!", + toString())); + } _alreadySet = true; diff --git a/include/tclap/ValueArg.h b/include/tclap/ValueArg.h index 28117f6..dbaf3bf 100644 --- a/include/tclap/ValueArg.h +++ b/include/tclap/ValueArg.h @@ -335,7 +335,15 @@ bool ValueArg::processArg(int *i, std::vector& args) if ( argMatches( flag ) ) { if ( _alreadySet ) - throw( CmdLineParseException("Argument already set!", toString()) ); + { + if ( _xorSet ) + throw( CmdLineParseException( + "Mutually exclusive argument already set!", + toString()) ); + else + throw( CmdLineParseException("Argument already set!", + toString()) ); + } if ( Arg::delimiter() != ' ' && value == "" ) throw( ArgParseException( diff --git a/tests/test22.out b/tests/test22.out index 77ee1c8..76153be 100644 --- a/tests/test22.out +++ b/tests/test22.out @@ -1,5 +1,5 @@ PARSE ERROR: Argument: -b (--bbb) - Argument already set! + Mutually exclusive argument already set! Brief USAGE: ../examples/test5 {-a |-b } {--eee |--fff diff --git a/tests/test24.out b/tests/test24.out index 77ee1c8..76153be 100644 --- a/tests/test24.out +++ b/tests/test24.out @@ -1,5 +1,5 @@ PARSE ERROR: Argument: -b (--bbb) - Argument already set! + Mutually exclusive argument already set! Brief USAGE: ../examples/test5 {-a |-b } {--eee |--fff