From 8e92fec9fa43c5df37f57619eb826f11d6637509 Mon Sep 17 00:00:00 2001 From: nguyenhoangthuan99 Date: Fri, 4 Oct 2024 09:22:50 +0700 Subject: [PATCH 1/2] fix: skip unexpect deleted model when list model --- engine/commands/model_list_cmd.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/engine/commands/model_list_cmd.cc b/engine/commands/model_list_cmd.cc index a871dc65c..653b4ef01 100644 --- a/engine/commands/model_list_cmd.cc +++ b/engine/commands/model_list_cmd.cc @@ -30,10 +30,19 @@ void ModelListCmd::Exec() { // auto model_entry = modellist_handler.GetModelInfo(model_handle); try { count += 1; - yaml_handler.ModelConfigFromFile( - fmu::ToAbsoluteCortexDataPath( - fs::path(model_entry.path_to_model_yaml)) - .string()); + try { + yaml_handler.ModelConfigFromFile( + fmu::ToAbsoluteCortexDataPath( + fs::path(model_entry.path_to_model_yaml)) + .string()); + + } catch (const std::exception& e) { + CTL_WRN("Fail to get model '" + model_entry.model + + "' information: " + std::string(e.what())); + yaml_handler.Reset(); + count -= 1; + continue; + } auto model_config = yaml_handler.GetModelConfig(); table.add_row({std::to_string(count), model_entry.model, model_entry.model_alias, model_config.engine, From abd12fdb88edaebcb91c9d39c8cb86c9ddf6ac89 Mon Sep 17 00:00:00 2001 From: nguyenhoangthuan99 Date: Fri, 4 Oct 2024 09:41:39 +0700 Subject: [PATCH 2/2] fix: comment --- engine/commands/model_list_cmd.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engine/commands/model_list_cmd.cc b/engine/commands/model_list_cmd.cc index 653b4ef01..14f929c93 100644 --- a/engine/commands/model_list_cmd.cc +++ b/engine/commands/model_list_cmd.cc @@ -29,20 +29,19 @@ void ModelListCmd::Exec() { for (const auto& model_entry : list_entry.value()) { // auto model_entry = modellist_handler.GetModelInfo(model_handle); try { - count += 1; try { yaml_handler.ModelConfigFromFile( fmu::ToAbsoluteCortexDataPath( fs::path(model_entry.path_to_model_yaml)) .string()); - } catch (const std::exception& e) { CTL_WRN("Fail to get model '" + model_entry.model + "' information: " + std::string(e.what())); yaml_handler.Reset(); - count -= 1; continue; } + + count += 1; auto model_config = yaml_handler.GetModelConfig(); table.add_row({std::to_string(count), model_entry.model, model_entry.model_alias, model_config.engine,