On error, one should exit and not abort. Aborting bypasses destructors and dumps core. It is harsh
and potentially dangerous. We want a nice error message, even when exceptions and disabled, not a "dumping core" message.
This commit is contained in:
parent
12bc8d78e7
commit
74a76a96f4
@ -480,11 +480,10 @@ namespace cxxopts
|
||||
throw T{text};
|
||||
#else
|
||||
// Otherwise manually instantiate the exception, print what() to stderr,
|
||||
// and abort
|
||||
// and exit
|
||||
T exception{text};
|
||||
std::cerr << exception.what() << std::endl;
|
||||
std::cerr << "Aborting (exceptions disabled)..." << std::endl;
|
||||
std::abort();
|
||||
std::exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user