YangSchema: Throw on enabling invalid features
Bug: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/181
Change-Id: Iad3c37098308da752ab7fbca95d900fbe67605d2
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 96b7e6e..4b65e13 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -374,12 +374,14 @@
void YangSchema::enableFeature(const std::string& moduleName, const std::string& featureName)
{
+ using namespace std::string_literals;
auto module = getYangModule(moduleName);
if (!module) {
- using namespace std::string_literals;
throw std::runtime_error("Module \""s + moduleName + "\" doesn't exist.");
}
- module->feature_enable(featureName.c_str());
+ if (module->feature_enable(featureName.c_str())) {
+ throw std::runtime_error("Can't enable feature \""s + featureName + "\" for module \"" + moduleName + "\".");
+ }
}
void YangSchema::registerModuleCallback(const std::function<std::string(const char*, const char*, const char*, const char*)>& clb)