]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- cleaner code
authorArvin Schnell <aschnell@suse.de>
Fri, 7 Oct 2011 09:34:00 +0000 (11:34 +0200)
committerArvin Schnell <aschnell@suse.de>
Fri, 7 Oct 2011 09:34:00 +0000 (11:34 +0200)
snapper/Exception.h
snapper/XmlFile.cc

index b885db76ba26828dfaf1258359497fd42ac4416e..0c628fa42b19350e96a425ac09615478a00459ef 100644 (file)
@@ -50,6 +50,12 @@ namespace snapper
        virtual const char* what() const throw() { return "illegal snapshot"; }
     };
 
+    struct BadAllocException : public SnapperException
+    {
+       explicit BadAllocException() throw() {}
+       virtual const char* what() const throw() { return "bad alloc"; }
+    };
+
     struct LogicErrorException : public SnapperException
     {
        explicit LogicErrorException() throw() {}
index 42499d8e0225622d8db55a9b4a2772fc809ebd1a..1ae64952d6bfad7a51fdc32738e4bf5b486079ce 100644 (file)
@@ -32,6 +32,8 @@ namespace snapper
     XmlFile::XmlFile()
        : doc(xmlNewDoc((const xmlChar*) "1.0"))
     {
+       if (!doc)
+           throw BadAllocException();
     }
 
 
@@ -45,8 +47,7 @@ namespace snapper
 
     XmlFile::~XmlFile()
     {
-       if (doc)
-           xmlFreeDoc(doc);
+       xmlFreeDoc(doc);
     }