Must catch and translate exceptions on top level

This commit is contained in:
Dmitry-Me 2014-09-23 06:10:41 +02:00 committed by Daniel Marjamäki
parent 47a3548bea
commit f63dc86f03
2 changed files with 23 additions and 5 deletions

View File

@ -119,7 +119,17 @@ int main(int argc, char* argv[])
GetModuleFileNameA(NULL, exename, sizeof(exename)/sizeof(exename[0])-1);
argv[0] = exename;
#endif
try {
return exec.check(argc, argv);
} catch (const InternalError& e) {
printf("%s\n", e.errorMessage.c_str());
} catch (const std::exception& error) {
printf("%s\n", error.what());
} catch (...) {
printf("Unknown exception\n");
}
return EXIT_FAILURE;
}

View File

@ -22,9 +22,17 @@
int main(int argc, char *argv[])
{
try {
options args(argc, const_cast<const char**>(argv));
std::size_t failedTestsCount = TestFixture::runTests(args);
return (failedTestsCount == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
} catch (const InternalError& e) {
printf("%s\n", e.errorMessage.c_str());
} catch (const std::exception& error) {
printf("%s\n", error.what());
} catch (...) {
printf("Unknown exception\n");
}
return EXIT_FAILURE;
}