Commit 8955375eb23d7278d293c6d264893a9f97845e7b
Committed by
Henry Schreiner
1 parent
852929f0
Making sure just catching Error works
Showing
1 changed file
with
6 additions
and
3 deletions
include/CLI/App.hpp
| ... | ... | @@ -29,10 +29,8 @@ namespace CLI { |
| 29 | 29 | #define CLI11_PARSE(app, argc, argv) \ |
| 30 | 30 | try { \ |
| 31 | 31 | (app).parse((argc), (argv)); \ |
| 32 | - } catch(const CLI::ParseError &e) { \ | |
| 32 | + } catch(const CLI::Error &e) { \ | |
| 33 | 33 | return (app).exit(e); \ |
| 34 | - } catch(const CLI::RuntimeError &e) { \ | |
| 35 | - return e.get_exit_code(); \ | |
| 36 | 34 | } |
| 37 | 35 | #endif |
| 38 | 36 | |
| ... | ... | @@ -682,6 +680,11 @@ class App { |
| 682 | 680 | |
| 683 | 681 | /// Print a nice error message and return the exit code |
| 684 | 682 | int exit(const Error &e) const { |
| 683 | + | |
| 684 | + /// Avoid printing anything if this is a CLI::RuntimeError | |
| 685 | + if(dynamic_cast<const CLI::RuntimeError*>(&e) != nullptr) | |
| 686 | + return e.get_exit_code(); | |
| 687 | + | |
| 685 | 688 | if(e.exit_code != static_cast<int>(ExitCodes::Success)) { |
| 686 | 689 | std::cerr << "ERROR: "; |
| 687 | 690 | std::cerr << e.what() << std::endl; | ... | ... |