diff --git a/cli/main.cpp b/cli/main.cpp index 5204ca4f7..7906726f3 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -119,7 +119,17 @@ int main(int argc, char* argv[]) GetModuleFileNameA(NULL, exename, sizeof(exename)/sizeof(exename[0])-1); argv[0] = exename; #endif - return exec.check(argc, argv); + + 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; } diff --git a/test/testrunner.cpp b/test/testrunner.cpp index ea32c6885..d99ccb471 100644 --- a/test/testrunner.cpp +++ b/test/testrunner.cpp @@ -22,9 +22,17 @@ int main(int argc, char *argv[]) { - options args(argc, const_cast(argv)); + try { + options args(argc, const_cast(argv)); - std::size_t failedTestsCount = TestFixture::runTests(args); - - return (failedTestsCount == 0) ? EXIT_SUCCESS : EXIT_FAILURE; + 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; }