From c60468fed42df70e4897d9144a89db55ffbf9af3 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Thu, 5 Dec 2024 17:02:06 +0100 Subject: Localize error_msg argument of ParseRoot ...and use expected to replace it. --- src/buildtool/main/main.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/buildtool/main/main.cpp') diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 34125fcd..6a37feec 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -551,12 +551,12 @@ auto DetermineRoots(gsl::not_null const& repository_config, repos[main_repo] = nlohmann::json::object(); } - std::string error_msg; for (auto const& [repo, desc] : repos.items()) { std::optional ws_root{}; bool const is_main_repo{repo == main_repo}; auto it_ws = desc.find("workspace_root"); if (it_ws != desc.end()) { + std::string error_msg; if (auto parsed_root = FileRoot::ParseRoot( repo, "workspace_root", *it_ws, &error_msg)) { ws_root = std::move(parsed_root->first); @@ -589,14 +589,13 @@ auto DetermineRoots(gsl::not_null const& repository_config, std::exit(kExitFailure); } auto info = RepositoryConfig::RepositoryInfo{std::move(*ws_root)}; - auto parse_keyword_root = [&desc = desc, - &repo = repo, - &error_msg = error_msg, - is_main_repo](FileRoot* keyword_root, - std::string const& keyword, - auto const& keyword_carg) { + auto parse_keyword_root = [&desc = desc, &repo = repo, is_main_repo]( + FileRoot* keyword_root, + std::string const& keyword, + auto const& keyword_carg) { auto it = desc.find(keyword); if (it != desc.end()) { + std::string error_msg; if (auto parsed_root = FileRoot::ParseRoot(repo, keyword, *it, &error_msg)) { (*keyword_root) = parsed_root->first; -- cgit v1.2.3