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/storage/backend_description.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/buildtool/storage/backend_description.cpp') diff --git a/src/buildtool/storage/backend_description.cpp b/src/buildtool/storage/backend_description.cpp index 456f79c6..c5f790aa 100644 --- a/src/buildtool/storage/backend_description.cpp +++ b/src/buildtool/storage/backend_description.cpp @@ -23,9 +23,18 @@ auto DescribeBackend(std::optional const& address, ExecutionProperties const& properties, std::vector const& dispatch) noexcept -> expected { - auto description = nlohmann::json{ - {"remote_address", address ? address->ToJson() : nlohmann::json{}}, - {"platform_properties", properties}}; + nlohmann::json description; + try { + description["remote_address"] = + address ? address->ToJson() : nlohmann::json{}; + description["platform_properties"] = properties; + } catch (std::exception const& e) { + return unexpected{ + fmt::format("Failed to serialize remote address and " + "platform_properties:\n{}", + e.what())}; + } + if (not dispatch.empty()) { try { // only add the dispatch list, if not empty, so that keys remain -- cgit v1.2.3