From ae62e371a9221c532fbdb6245ea6232dc1c53aca Mon Sep 17 00:00:00 2001 From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de> Date: Tue, 13 Jun 2023 11:47:38 +0000 Subject: [PATCH] Options.cxx: Improve error handling and help display. --- algo/base/Options.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/algo/base/Options.cxx b/algo/base/Options.cxx index 2cdc945bbd..79fc95edaa 100644 --- a/algo/base/Options.cxx +++ b/algo/base/Options.cxx @@ -77,14 +77,14 @@ Options::Options(int argc, char** argv) auto result = parser.run(); 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 << cmdline_options << std::endl; + std::cerr << "Use '-h' to display all valid options." << std::endl; std::exit(EXIT_FAILURE); } - if (vm.count("help")) { - std::cerr << cmdline_options << std::endl; + if (vm.count("help") > 0) { + std::cout << cmdline_options << std::endl; std::exit(EXIT_SUCCESS); } @@ -93,7 +93,7 @@ Options::Options(int argc, char** argv) } catch (const po::required_option& e) { 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); } } -- GitLab