From 6e74b1448bf8d94d73ef3134aa9e8bf36e51a2aa Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 2 Oct 2024 16:03:45 +0200 Subject: Enable bugprone-exception-escape check --- src/buildtool/serve_api/remote/target_client.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/buildtool/serve_api/remote/target_client.cpp') diff --git a/src/buildtool/serve_api/remote/target_client.cpp b/src/buildtool/serve_api/remote/target_client.cpp index f339172f..972b9708 100644 --- a/src/buildtool/serve_api/remote/target_client.cpp +++ b/src/buildtool/serve_api/remote/target_client.cpp @@ -91,14 +91,16 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, // add dispatch information to request, while ensuring blob is uploaded // to remote cas - auto dispatch_list = nlohmann::json::array(); + std::optional dispatch_digest; try { + auto dispatch_list = nlohmann::json::array(); for (auto const& [props, endpoint] : exec_config_.dispatch) { auto entry = nlohmann::json::array(); entry.push_back(nlohmann::json(props)); entry.push_back(endpoint.ToJson()); dispatch_list.push_back(entry); } + dispatch_digest = storage_.CAS().StoreBlob(dispatch_list.dump(2)); } catch (std::exception const& ex) { return serve_target_result_t{ std::in_place_index<1>, @@ -106,14 +108,12 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, ex.what())}; } - auto dispatch_dgst = storage_.CAS().StoreBlob(dispatch_list.dump(2)); - if (not dispatch_dgst) { + if (not dispatch_digest) { return serve_target_result_t{ - std::in_place_index<1>, - fmt::format("Failed to store blob {} to local cas", - dispatch_list.dump(2))}; + std::in_place_index<1>, "Failed to add dispatch info to local cas"}; } - auto const dispatch_info = Artifact::ObjectInfo{.digest = *dispatch_dgst, + + auto const dispatch_info = Artifact::ObjectInfo{.digest = *dispatch_digest, .type = ObjectType::File}; if (not apis_.local->RetrieveToCas({dispatch_info}, *apis_.remote)) { return serve_target_result_t{ @@ -122,7 +122,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, dispatch_info.ToString())}; } (*request.mutable_dispatch_info()) = - ArtifactDigestFactory::ToBazel(*dispatch_dgst); + ArtifactDigestFactory::ToBazel(*dispatch_digest); // call rpc grpc::ClientContext context; -- cgit v1.2.3