error handling

This commit is contained in:
Scott E. Graves 2025-02-20 18:48:41 -06:00
parent 37ca295f41
commit 4ae32c7292

View File

@ -187,8 +187,8 @@ auto load_config(std::string &cfg_file) -> app_config {
};
auto iter = std::ranges::find_first_of(
cfg.server_list, id_names, [](auto &&data, auto &&name) -> bool {
return utils::string::contains(data.id, name);
cfg.server_list, id_names, [](auto &&srv, auto &&name) -> bool {
return utils::string::contains(srv.id, name);
});
if (iter == cfg.server_list.end()) {
throw utils::error::create_exception(
@ -198,6 +198,31 @@ auto load_config(std::string &cfg_file) -> app_config {
fmt::format("{}", id_names),
});
}
// std::ranges::for_each(id_names, [&](std::string_view name) {
// std::ranges::for_each(cfg.server_list, [&](auto &&srv) {
// auto count = std::ranges::count(srv.id, name);
// });
// auto count = std::ranges::count(
// std::accumulate(cfg.server_list.begin(), cfg.server_list.end(),
// std::vector<std::string_view>(),
// [](auto &&list, auto &&srv) {
// list.push_back(srv.id);
// return list;
// }),
// name);
// if (count <= 1U) {
// return;
// }
//
// throw utils::error::create_exception(
// function_name, {
// "server id",
// name,
// "must contain only one of the following
// values", fmt::format("{}", id_names),
// });
// });
}
return cfg;