make error message a bit more meaningful

This commit is contained in:
mes5k 2009-10-25 03:49:00 +00:00
parent ab82cc7f87
commit b8b1bb2467
4 changed files with 20 additions and 4 deletions

View File

@ -197,7 +197,15 @@ inline bool SwitchArg::processArg(int *i, std::vector<std::string>& 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;

View File

@ -335,7 +335,15 @@ bool ValueArg<T>::processArg(int *i, std::vector<std::string>& 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(

View File

@ -1,5 +1,5 @@
PARSE ERROR: Argument: -b (--bbb)
Argument already set!
Mutually exclusive argument already set!
Brief USAGE:
../examples/test5 {-a <string>|-b <string>} {--eee <string>|--fff

View File

@ -1,5 +1,5 @@
PARSE ERROR: Argument: -b (--bbb)
Argument already set!
Mutually exclusive argument already set!
Brief USAGE:
../examples/test5 {-a <string>|-b <string>} {--eee <string>|--fff