From 8955375eb23d7278d293c6d264893a9f97845e7b Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Mon, 20 Nov 2017 10:00:11 -0500 Subject: [PATCH] Making sure just catching Error works --- include/CLI/App.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 8bc787c9..9ab0a331 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -29,10 +29,8 @@ namespace CLI { #define CLI11_PARSE(app, argc, argv) \ try { \ (app).parse((argc), (argv)); \ - } catch(const CLI::ParseError &e) { \ + } catch(const CLI::Error &e) { \ return (app).exit(e); \ - } catch(const CLI::RuntimeError &e) { \ - return e.get_exit_code(); \ } #endif @@ -682,6 +680,11 @@ class App { /// Print a nice error message and return the exit code int exit(const Error &e) const { + + /// Avoid printing anything if this is a CLI::RuntimeError + if(dynamic_cast(&e) != nullptr) + return e.get_exit_code(); + if(e.exit_code != static_cast(ExitCodes::Success)) { std::cerr << "ERROR: "; std::cerr << e.what() << std::endl;