From 2458c7bb6c431e9eea07e063e43e72e203a88aa0 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Fri, 8 Oct 2021 17:27:05 +0200 Subject: [PATCH] Return EXIT_FAILURE if one of the compilation units failed --- src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a323611..1028654 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,6 +38,7 @@ int main(int argc, char* argv[]) { outputFileContent(outputFile, transpiledString); return transpiledString; }; + int8_t exit_code = EXIT_SUCCESS; if (!files.empty()) { vector>>> Units(files.size()); const launch& Policy = not parallel ? launch::deferred : launch::async; @@ -66,14 +67,16 @@ int main(int argc, char* argv[]) { }); }); if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n"; - for_each(Units.begin(), Units.end(), [&printResult](future>>& currentFuture) { + exit_code = none_of(Units.rbegin(), Units.rend(), [&printResult](future>>& currentFuture) -> bool { const auto&& result = currentFuture.get(); - if (not result.second.has_value()) { + const bool is_exception = result.second.has_value(); + if (not is_exception) { if (printResult) cout << result.first << '\n'; } else { cout << "Compilation of " << result.first << " has failed with the following error:\n" << result.second.value().what() << '\n'; } - }); + return is_exception; + }) ? EXIT_SUCCESS : EXIT_FAILURE; } else cout << "No valid file provided.\n"; - return EXIT_SUCCESS; + return exit_code; } \ No newline at end of file