Changeset 2352


Ignore:
Timestamp:
Nov 27, 2010, 1:09:14 AM (11 years ago)
Author:
Peter
Message:

fixes #645. error message is now: invalid argument --bar'

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/commandline_test.cc

    r2202 r2352  
    437437  }
    438438
     439  // test for ticket 645
     440  suite.err() << "Testing error message with -n STRING\n";
     441  try {
     442    int ac = 3;
     443    const char* cav[] = { "test_prog", "-n", "STRING"};
     444    char** av = stradup(cav, ac);
     445    try {
     446      cmd.parse(ac,av);
     447      strafree(av, ac);
     448      ok=false;
     449      suite.err() << "error: expected parse to throw\n";
     450    }
     451    catch (std::runtime_error& e) {
     452      strafree(av, ac);
     453      suite.err() << "expected exception: what(): " << e.what() << "\n";
     454    }
     455  }
     456  catch (std::runtime_error& e) {
     457    suite.err() << "failed: " << e.what() << "\n";
     458    ok=false;
     459  }
    439460  return ok;
    440461}
  • trunk/yat/utility/OptionArg.h

    r2210 r2352  
    147147      catch (runtime_error& e) {
    148148        std::stringstream sstr(rhs);
    149         sstr << ": invalid argument";
     149        sstr << "invalid argument";
     150        sstr << "`" << rhs << "' for `";
     151        if (!long_name().empty())
     152          sstr << "--" << long_name();
     153        else
     154          sstr << "-" << short_name();
     155        sstr << "'";
    150156        throw cmd_error(sstr.str());
    151157      }
Note: See TracChangeset for help on using the changeset viewer.