From 34d574a9dab733b70b7445b38c8f483807f053ea Mon Sep 17 00:00:00 2001 From: itsafuu <89619301+itsafuu@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:26:08 -0400 Subject: [PATCH] Additional error handling [ci skip] --- src/processing/impl/processing_core_impl.cpp | 11 ++++++++--- src/processing/impl/processing_core_impl.hpp | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/processing/impl/processing_core_impl.cpp b/src/processing/impl/processing_core_impl.cpp index d9b70705..c5cd3af8 100644 --- a/src/processing/impl/processing_core_impl.cpp +++ b/src/processing/impl/processing_core_impl.cpp @@ -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; } @@ -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; diff --git a/src/processing/impl/processing_core_impl.hpp b/src/processing/impl/processing_core_impl.hpp index 279d190b..ce6061f9 100644 --- a/src/processing/impl/processing_core_impl.hpp +++ b/src/processing/impl/processing_core_impl.hpp @@ -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; } }