From 2456f6965586bca6b3ee90d407ea433120f91b54 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Mon, 16 Dec 2024 11:15:11 +0100 Subject: [PATCH] error no model found --- src/solver/systemParser/converter.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/solver/systemParser/converter.cpp b/src/solver/systemParser/converter.cpp index 40e8bf6d5d..20e8fd0d4a 100644 --- a/src/solver/systemParser/converter.cpp +++ b/src/solver/systemParser/converter.cpp @@ -49,6 +49,15 @@ class LibraryNotFound: public std::runtime_error } }; +class ModelNotFound: public std::runtime_error +{ +public: + explicit ModelNotFound(const std::string& s): + runtime_error("No model found with this name: " + s) + { + } +}; + static std::pair splitLibraryModelString(const std::string& s) { size_t pos = s.find('.'); @@ -73,8 +82,15 @@ static const SystemModel::Model* getModel(const std::vectorModels().at(modelId); - return &model; + try + { + auto& model = lib->Models().at(modelId); + return &model; + } + catch (const std::out_of_range&) + { + throw ModelNotFound(modelId); + } } static SystemModel::Component createComponent(const SystemParser::Component& c,