diff options
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 |