mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-03 14:03:52 +00:00
Making sure just catching Error works
This commit is contained in:
parent
852929f0f6
commit
8955375eb2
@ -29,10 +29,8 @@ namespace CLI {
|
|||||||
#define CLI11_PARSE(app, argc, argv) \
|
#define CLI11_PARSE(app, argc, argv) \
|
||||||
try { \
|
try { \
|
||||||
(app).parse((argc), (argv)); \
|
(app).parse((argc), (argv)); \
|
||||||
} catch(const CLI::ParseError &e) { \
|
} catch(const CLI::Error &e) { \
|
||||||
return (app).exit(e); \
|
return (app).exit(e); \
|
||||||
} catch(const CLI::RuntimeError &e) { \
|
|
||||||
return e.get_exit_code(); \
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -682,6 +680,11 @@ class App {
|
|||||||
|
|
||||||
/// Print a nice error message and return the exit code
|
/// Print a nice error message and return the exit code
|
||||||
int exit(const Error &e) const {
|
int exit(const Error &e) const {
|
||||||
|
|
||||||
|
/// Avoid printing anything if this is a CLI::RuntimeError
|
||||||
|
if(dynamic_cast<const CLI::RuntimeError*>(&e) != nullptr)
|
||||||
|
return e.get_exit_code();
|
||||||
|
|
||||||
if(e.exit_code != static_cast<int>(ExitCodes::Success)) {
|
if(e.exit_code != static_cast<int>(ExitCodes::Success)) {
|
||||||
std::cerr << "ERROR: ";
|
std::cerr << "ERROR: ";
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user