Skip to content

Commit

Permalink
error no model found
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 16, 2024
1 parent 62c2b1c commit 2456f69
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/solver/systemParser/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::string> splitLibraryModelString(const std::string& s)
{
size_t pos = s.find('.');
Expand All @@ -73,8 +82,15 @@ static const SystemModel::Model* getModel(const std::vector<SystemModel::Library
throw LibraryNotFound(libraryId);
}

auto& model = lib->Models().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,
Expand Down

0 comments on commit 2456f69

Please sign in to comment.