fix(studio/host): corrections signalées par clangd

Initialiseurs désignés pour ParsedOptions, RequestResult et Error ; candidate non const dans find_ui_dir pour permettre le déplacement au retour ; ErrorCode sur std::uint8_t.
This commit is contained in:
Ange-Marie MAURIN - A2M Systèmes committed 2026-11-07 04:37:59 +01:00
1 parent 83fe5666ff
commit 203e9ed9b6
3 files changed
+9 -6

No files matched your search

+5 -4
View File
@@ -66,7 +66,7 @@ ParsedOptions parse_options(std::span<const std::string_view> args)
for (std::size_t i = 0; i < args.size(); ++i) {
const std::string_view arg = args[i];
const bool has_value = i + 1 < args.size();
const auto fail = [](std::string message) { return ParsedOptions{std::nullopt, std::move(message)}; };
const auto fail = [](std::string message) { return ParsedOptions{.options=std::nullopt, .error=std::move(message)}; };
if (arg == "--help" || arg == "-h") {
options.help = true;
} else if (arg == "--detach-core") {
@@ -101,9 +101,9 @@ ParsedOptions parse_options(std::span<const std::string_view> args)
}
}
if (options.core_port == options.ui_port) {
return {std::nullopt, "Le Core et l'interface ne peuvent pas partager le même port."};
return {.options=std::nullopt, .error="Le Core et l'interface ne peuvent pas partager le même port."};
}
return {options, {}};
return {.options=options, .error={}};
}
std::optional<std::filesystem::path> find_core_exe(const std::filesystem::path& exe_dir)
@@ -124,7 +124,8 @@ std::optional<std::filesystem::path> find_ui_dir(const std::filesystem::path& ex
{
for (std::filesystem::path dir = exe_dir; dir.has_parent_path() && dir != dir.parent_path();
dir = dir.parent_path()) {
const auto candidate = dir / "studio" / "ui" / "dist";
// const auto candidate = dir / "studio" / "ui" / "dist";
auto candidate = dir / "studio" / "ui" / "dist";
if (is_file(candidate / "index.html")) {
return candidate;
}
+3 -1
View File
@@ -55,7 +55,9 @@ std::string StudioHost::core_url() const
RequestResult StudioHost::request(const std::string& type, const json& payload, std::chrono::milliseconds timeout)
{
if (!client_) {
return {std::nullopt, Error{ErrorCode::NotConnected, "Pas de connexion au Core.", {}, 0}};
return {.value=std::nullopt,
.error = Error{.code=ErrorCode::NotConnected,.message= "Pas de connexion au Core.", .server_code={}, .close_code= 0}
};
}
return client_->request(type, payload, timeout);
}
@@ -32,7 +32,7 @@ struct Welcome {
};
// Catégorie d'erreur renvoyée par le client.
enum class ErrorCode {
enum class ErrorCode : std::uint8_t {
NotConnected, // aucune connexion ouverte au moment de la requête
Timeout, // délai dépassé (connexion ou réponse)
ConnectFailed, // connexion réseau impossible (hôte/port injoignable)