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:
Daniel Lemire 2020-05-28 10:09:46 -04:00
parent 12bc8d78e7
commit 74a76a96f4

View File

@ -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
}