Don't output useless new lines in main.cpp

This commit is contained in:
Username404-59 2021-10-08 13:07:13 +02:00
parent dc21af192b
commit 429ed02483
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 5 additions and 4 deletions

View File

@ -40,7 +40,9 @@ namespace Yerbacon {
[[nodiscard]] const char* what() const noexcept final {
return exceptionCause.data();
}
explicit Exception(const std::string_view& cause): exceptionCause(cause) {}
explicit Exception(const std::string_view& cause): exceptionCause(cause) {
if (!cause.ends_with('\n')) exceptionCause += '\n';
}
Exception(const std::string_view& cause, unsigned long line): Exception(('L' + std::to_string(line) + ": ").append(cause)) {}
};
}

View File

@ -68,11 +68,10 @@ int main(int argc, char* argv[]) {
for_each(Units.begin(), Units.end(), [&printResult](future<pair<string, optional<Yerbacon::Exception>>>& currentFuture) {
const auto&& result = currentFuture.get();
if (not result.second.has_value()) {
if (printResult) cout << result.first;
if (printResult) cout << result.first << '\n';
} else {
cout << "Compilation of " << result.first << " has failed with the following error:\n" << result.second.value().what();
cout << "Compilation of " << result.first << " has failed with the following error:\n" << result.second.value().what() << '\n';
}
cout << "\n\n";
});
} else cout << "No valid file provided.\n";
return EXIT_SUCCESS;