X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fgetopt.cpp;h=ad726448589cc0ebc38255cd7790cdbbaf0e0136;hp=34e53172aeb194d1cebc29c7df4de8719add8c27;hb=9c6c946ed658abd50be9d597cb2c722592d660ae;hpb=87edba02a23b1338934e36fac407966b25fcf811 diff --git a/source/core/getopt.cpp b/source/core/getopt.cpp index 34e5317..ad72644 100644 --- a/source/core/getopt.cpp +++ b/source/core/getopt.cpp @@ -257,22 +257,38 @@ void GetOpt::OptBase::process() { if(arg_type==REQUIRED_ARG) throw usage_error("--"+lng+" requires an argument"); + ++seen_count; if(ext_seen_count) *ext_seen_count = seen_count; - store(); + try + { + store(); + } + catch(const exception &e) + { + throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")"); + } } void GetOpt::OptBase::process(const string &arg) { if(arg_type==NO_ARG) throw usage_error("--"+lng+" takes no argument"); + ++seen_count; if(ext_seen_count) *ext_seen_count = seen_count; - store(arg); + try + { + store(arg); + } + catch(const exception &e) + { + throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")"); + } } } // namespace Msp