]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- fixed error handling when reading configs (gh#openSUSE/snapper#715) 717/head
authorArvin Schnell <aschnell@suse.de>
Tue, 3 May 2022 06:47:41 +0000 (08:47 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 3 May 2022 06:47:41 +0000 (08:47 +0200)
LIBVERSION
package/snapper.changes
snapper/Selinux.cc
snapper/Snapper.cc

index 09b254e90c61ed28bb68a54752cf04f6a736a7d3..5fe60723048a9d28c605f5359e50d70d3ea78bf6 100644 (file)
@@ -1 +1 @@
-6.0.0
+6.0.1
index 8cf8ec066d9d3b0e1573eeb5fae53da6c9f7d3c8..9eca5d09bd81c8ede0dd4dd07264ab5fbb0c62d5 100644 (file)
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Tue May 03 08:46:28 CEST 2022 - aschnell@suse.com
+
+- fixed error handling when reading configs
+  (gh#openSUSE/snapper#715)
+
 -------------------------------------------------------------------
 Thu Apr 21 09:35:06 CEST 2022 - aschnell@suse.com
 
index 61c1de42357542a938cbc760db611b461fae0b85..fefb2c62938a00d67351da801b9ff21da8c9b8bf 100644 (file)
 namespace snapper
 {
 
+    using std::map;
+
+
     SnapperContexts::SnapperContexts()
     {
-       std::map<string,string> snapperd_contexts;
+       map<string, string> snapperd_contexts;
 
        try
        {
@@ -59,13 +62,13 @@ namespace snapper
                }
            }
        }
-       catch (const FileNotFoundException& e)
+       catch (const Exception& e)
        {
            SN_CAUGHT(e);
            SN_THROW(SelinuxException("Failed to parse contexts file"));
        }
 
-       std::map<string,string>::const_iterator cit = snapperd_contexts.find(selinux_snapperd_data);
+       map<string, string>::const_iterator cit = snapperd_contexts.find(selinux_snapperd_data);
        if (cit == snapperd_contexts.end())
        {
            SN_THROW(SelinuxException("Snapperd data context not found"));
index 6a4d1395bc18fc36ec1fd7f5d2e2e1f3a6b4799a..87303500899a71faf6f2b89aee392f35f723f88d 100644 (file)
@@ -111,7 +111,7 @@ namespace snapper
        {
            config_info = new ConfigInfo(config_name, root_prefix);
        }
-       catch (const FileNotFoundException& e)
+       catch (const Exception& e)
        {
            SN_CAUGHT(e);
 
@@ -307,31 +307,25 @@ namespace snapper
            vector<string> config_names;
            sysconfig.get_value("SNAPPER_CONFIGS", config_names);
 
-           for (vector<string>::const_iterator it = config_names.begin(); it != config_names.end(); ++it)
+           for (const string& config_name : config_names)
            {
                try
                {
-                   config_infos.push_back(getConfig(*it, root_prefix));
-               }
-               catch (const FileNotFoundException& e)
-               {
-                   SN_CAUGHT(e);
-
-                   y2err("config '" << *it << "' not found");
+                   config_infos.push_back(getConfig(config_name, root_prefix));
                }
-               catch (const InvalidConfigException& e)
+               catch (const Exception& e)
                {
                    SN_CAUGHT(e);
 
-                   y2err("config '" << *it << "' is invalid");
+                   y2err("reading config '" << config_name << "' failed");
                }
            }
        }
-       catch (const FileNotFoundException& e)
+       catch (const Exception& e)
        {
            SN_CAUGHT(e);
 
-           SN_THROW(ListConfigsFailedException("sysconfig-file not found"));
+           SN_THROW(ListConfigsFailedException("reading sysconfig-file failed"));
        }
 
        return config_infos;
@@ -411,7 +405,7 @@ namespace snapper
 
            sysconfig.save();
        }
-       catch (const FileNotFoundException& e)
+       catch (const Exception& e)
        {
            SN_CAUGHT(e);
 
@@ -429,7 +423,7 @@ namespace snapper
 
            config.save();
        }
-       catch (const FileNotFoundException& e)
+       catch (const Exception& e)
        {
            SN_CAUGHT(e);
 
@@ -524,11 +518,11 @@ namespace snapper
 
            sysconfig.save();
        }
-       catch (const FileNotFoundException& e)
+       catch (const Exception& e)
        {
            SN_CAUGHT(e);
 
-           SN_THROW(DeleteConfigFailedException("sysconfig-file not found"));
+           SN_THROW(DeleteConfigFailedException("modifying sysconfig-file failed"));
        }
     }