[program_options] Uncatchable Errors
I have a minimal program below that uses the program_options library. If executed with no options or with --help as an option, it correctly prints "End of option processing" and does nothing else. However, if you give it an unexpected option such as --x, then (in my case) Zone Alert pops up saying that "somone" is trying to launch Dr Watson. If the try/catch is omitted, a message is printed to the console: "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." Am I doing something wrong to make unexpected options behave so badly? Merrill ========================================== #include <iostream> #include <stdexcept> #include "boost/program_options.hpp" namespace po = boost::program_options; using namespace std; int main(int argc, char* argv[]) { try { po::options_description general_verbose("Options"); general_verbose.add_options() ("help,h", " Display this help message."); po::variables_map vm; po::store(po::command_line_parser(argc, argv). options(general_verbose).run(), vm); po::notify(vm); }//try catch(std::exception ex) { cout << "Exception: " << ex.what() << endl; } catch(...) { cout << "Unknown exception." << endl; } cout << "End of option processing." << endl; }//main()
participants (1)
-
Merrill Cornish