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