]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1077] netconf: throw, don't exit
authorAndrei Pavel <andrei@isc.org>
Thu, 22 Jul 2021 19:02:41 +0000 (22:02 +0300)
committerTomek Mrugalski <tomek@isc.org>
Fri, 23 Jul 2021 10:45:36 +0000 (10:45 +0000)
src/bin/netconf/netconf.cc
src/bin/netconf/netconf.h
src/bin/netconf/netconf_cfg_mgr.cc

index 780db0ed36ae98d5f8a73df2223a92c2f8077f4c..ddb3a6a9611a2bb9f27e638f9597a5406e280710 100644 (file)
@@ -272,19 +272,17 @@ void NetconfAgent::getModules() {
         S_Context context(running_sess_->get_context());
         modules = context->get_module_iter();
     } catch (const sysrepo_exception& ex) {
-        cerr << "ERROR: Can't retrieve available modules: " << ex.what() << endl;
-        exit(1);
+        isc_throw(Unexpected, "can't retrieve available modules: " << ex.what());
     }
 
     for (S_Module const& module : modules) {
         if (!module->name()) {
-            cerr << "ERROR: module name is mangled" << endl;
-            exit(2);
+            isc_throw(Unexpected, "could not retrieve module name");
         }
         string const name(module->name());
         if (!module->rev() || !module->rev()->date()) {
-            cerr << "ERROR: module revision is mangled" << endl;
-            exit(3);
+            isc_throw(Unexpected,
+                      "could not retrieve module revision for module " << name);
         }
         string const revision(module->rev()->date());
         modules_.emplace(name, revision);
@@ -328,11 +326,8 @@ NetconfAgent::checkModules(CfgServersMapPtr const& servers /* = {} */) const {
     }
 
     if (faulty_model) {
-        cerr << "ERROR: The logged YANG module is missing or its revision is not "
-                "supported. The environment is not suitable for running "
-                "kea-netconf."
-            << endl;
-        exit(4);
+        isc_throw(Unexpected, "YANG module is missing or its revision is not "
+                              "supported. Check logs for details.");
     }
 
     for (auto modrev : YANG_REVISIONS) {
index b28659472b5c088cf33528cb92cc77373488d8aa..d8cfc376117af9045fb2072d95b9067a1d2a4e0f 100644 (file)
@@ -107,7 +107,6 @@ protected:
     ///
     /// Emit a fatal error if an essential one (i.e. required in
     /// a further phase) is missing or does not have the expected revision.
-    /// The caller (init) will exit().
     ///
     /// @param module_name The module name.
     /// @return true if available, false if not.
index 1f889a73d5a03457a584bbbe3b38c332432a796b..82a19f2fe7c56c444d57af84d2c2d9a47fe8633c 100644 (file)
@@ -90,7 +90,7 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set,
                      bool check_only) {
     // Do a sanity check first.
     if (!config_set) {
-        isc_throw(DhcpConfigError, "Mandatory config parameter not provided");
+        isc_throw(ConfigError, "Mandatory config parameter not provided");
     }
 
     NetconfConfigPtr ctx = getNetconfConfig();