]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/getopt.cpp
Move GetOpt exception handling to the .cpp file
[libs/core.git] / source / core / getopt.cpp
index 34e53172aeb194d1cebc29c7df4de8719add8c27..ad726448589cc0ebc38255cd7790cdbbaf0e0136 100644 (file)
@@ -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