From ce7620f44d830d8434c9d4196ebe0f3f5ec68992 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Tue, 30 Apr 2024 23:13:56 +0200 Subject: [PATCH] Show proper error message on connection failure --- client/scenes/lobby.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index 023fb97a..9d6572ec 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -212,6 +212,7 @@ std::unique_ptr connect_to_session(wivrn_discover::service servic freeaddrinfo(addresses); } + std::string error; for (const auto & address: service.addresses) { std::string address_string = std::visit([](auto & address) { @@ -230,11 +231,15 @@ std::unique_ptr connect_to_session(wivrn_discover::service servic } catch (std::exception & e) { - spdlog::warn("Cannot connect to {} ({}): {}", service.hostname, address_string, e.what()); + std::string txt = fmt::format("Cannot connect to {} ({}): {}", service.hostname, address_string, e.what()); + spdlog::warn(txt); + if (not error.empty()) + error += "\n"; + error += txt; } } - throw std::runtime_error("No usable address"); + throw std::runtime_error(error); } static glm::mat4 projection_matrix(XrFovf fov, float zn = 0.02)