Skip to content

Commit

Permalink
Additional error handling [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
itsafuu committed Apr 9, 2024
1 parent b95080a commit 34d574a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/processing/impl/processing_core_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ namespace sgns::processing
//Set processor or fail.
if (!this->SetProcessingTypeFromJson(jsonString))
{
std::cerr << "settings.json has no processor name defined" << std::endl;
return;
}

Expand Down Expand Up @@ -113,9 +112,15 @@ namespace sgns::processing
const rapidjson::Value& model = doc["model"];
if (model.HasMember("name") && model["name"].IsString()) {
std::string modelName = model["name"].GetString();
SetProcessorByName(modelName);
std::cout << "Model name: " << modelName << std::endl;
return true;
if (SetProcessorByName(modelName))
{
return true;
}
else
{
std::cerr << "No processor by name in settings json" << std::endl;
}
}
else {
std::cerr << "Model name not found or not a string" << std::endl;
Expand Down
4 changes: 3 additions & 1 deletion src/processing/impl/processing_core_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ namespace sgns::processing
/** Set the current processor by name
* @param name - Name of processor
*/
void SetProcessorByName(const std::string& name) {
bool SetProcessorByName(const std::string& name) {
auto factoryFunction = m_processorFactories.find(name);
if (factoryFunction != m_processorFactories.end()) {
m_processor = factoryFunction->second();
return true;
}
else {
std::cerr << "Unknown processor name: " << name << std::endl;
return false;
}
}

Expand Down

0 comments on commit 34d574a

Please sign in to comment.