Skip to content
Snippets Groups Projects
Commit ae62e371 authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

Options.cxx: Improve error handling and help display.

parent f6ff6f24
No related branches found
No related tags found
1 merge request!1181cbmreco: Add flag to write logs to file.
Pipeline #22666 passed
...@@ -77,14 +77,14 @@ Options::Options(int argc, char** argv) ...@@ -77,14 +77,14 @@ Options::Options(int argc, char** argv)
auto result = parser.run(); auto result = parser.run();
po::store(result, vm); po::store(result, vm);
} }
catch (const boost::wrapexcept<po::unknown_option>& e) { catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl; std::cerr << "Error: " << e.what() << std::endl;
std::cerr << cmdline_options << std::endl; std::cerr << "Use '-h' to display all valid options." << std::endl;
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }
if (vm.count("help")) { if (vm.count("help") > 0) {
std::cerr << cmdline_options << std::endl; std::cout << cmdline_options << std::endl;
std::exit(EXIT_SUCCESS); std::exit(EXIT_SUCCESS);
} }
...@@ -93,7 +93,7 @@ Options::Options(int argc, char** argv) ...@@ -93,7 +93,7 @@ Options::Options(int argc, char** argv)
} }
catch (const po::required_option& e) { catch (const po::required_option& e) {
std::cerr << "Error: " << e.what() << std::endl; std::cerr << "Error: " << e.what() << std::endl;
std::cerr << cmdline_options << std::endl; std::cerr << "Use '-h' to display all valid options." << std::endl;
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment