Catch exceptions in main() only if NDEBUG is defined

This commit is contained in:
PKEuS 2014-09-28 09:51:18 +02:00
parent 03b1afc28c
commit 73171b0bc7
2 changed files with 8 additions and 0 deletions

View File

@ -123,8 +123,11 @@ int main(int argc, char* argv[])
argv[0] = exename;
#endif
#ifdef NDEBUG
try {
#endif
return exec.check(argc, argv);
#ifdef NDEBUG
} catch (const InternalError& e) {
printf("%s\n", e.errorMessage.c_str());
} catch (const std::exception& error) {
@ -133,6 +136,7 @@ int main(int argc, char* argv[])
printf("Unknown exception\n");
}
return EXIT_FAILURE;
#endif
}

View File

@ -23,11 +23,14 @@
int main(int argc, char *argv[])
{
#ifdef NDEBUG
try {
#endif
options args(argc, const_cast<const char**>(argv));
std::size_t failedTestsCount = TestFixture::runTests(args);
return (failedTestsCount == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
#ifdef NDEBUG
} catch (const InternalError& e) {
printf("%s\n", e.errorMessage.c_str());
} catch (const std::exception& error) {
@ -36,4 +39,5 @@ int main(int argc, char *argv[])
printf("Unknown exception\n");
}
return EXIT_FAILURE;
#endif
}