diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-10-02 16:03:45 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-10-07 13:37:39 +0200 |
commit | 6e74b1448bf8d94d73ef3134aa9e8bf36e51a2aa (patch) | |
tree | 535d3c7bdf73251379cff7b541d7e50c3beccca7 /src/buildtool/storage/backend_description.cpp | |
parent | e8085c1c209e98a31c32e2032d02d620449006e4 (diff) | |
download | justbuild-6e74b1448bf8d94d73ef3134aa9e8bf36e51a2aa.tar.gz |
Enable bugprone-exception-escape check
Diffstat (limited to 'src/buildtool/storage/backend_description.cpp')
-rw-r--r-- | src/buildtool/storage/backend_description.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
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<ServerAddress> const& address, ExecutionProperties const& properties, std::vector<DispatchEndpoint> const& dispatch) noexcept -> expected<std::string, std::string> { - 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 |