]> granicus.if.org Git - icinga2/commitdiff
Cleaned up exception handling.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 14 Aug 2012 07:51:11 +0000 (09:51 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 14 Aug 2012 07:51:11 +0000 (09:51 +0200)
base/dynamicobject.cpp
base/object.cpp
base/utility.cpp

index f9be9919333f84d37ac39a59de473e7766f8a5fe..13d82081d6bfb42dfd6290694833a87e92c8c192 100644 (file)
@@ -39,7 +39,7 @@ DynamicObject::DynamicObject(const Dictionary::Ptr& serializedObject)
        RegisterAttribute("methods", Attribute_Config);
 
        if (!serializedObject->Contains("configTx"))
-               throw invalid_argument("Serialized object must contain a config snapshot.");
+               throw_exception(invalid_argument("Serialized object must contain a config snapshot."));
 
        /* apply config state from the config item/remote update;
         * The DynamicObject::Create function takes care of restoring
@@ -406,7 +406,8 @@ void DynamicObject::DumpObjects(const String& filename)
                }
        }
 
-       rename(tempFilename.CStr(), filename.CStr());
+       if (rename(tempFilename.CStr(), filename.CStr()) < 0)
+               throw_exception(PosixException("rename() failed", errno));
 }
 
 void DynamicObject::RestoreObjects(const String& filename)
index 846912f6a4ee50e222e228cc83093f59306714fe..da68ed0fadb60242f0bf39587e7521923e25ebcb 100644 (file)
@@ -104,7 +104,8 @@ void Object::PrintMemoryProfile(void)
        }
 
        dictfp.close();
-       rename("dictionaries.dump.tmp", "dictionaries.dump");
+       if (rename("dictionaries.dump.tmp", "dictionaries.dump") < 0)
+               throw_exception(PosixException("rename() failed", errno));
 
        String type;
        int count;
index 79ae91ad83180bbe5da61a9a0fd62be7ea653b32..710655d90065d92be53fa3b24f21081c97f58217 100644 (file)
@@ -284,7 +284,7 @@ double Utility::GetTime(void)
        struct timeval tv;
 
        if (gettimeofday(&tv, NULL) < 0)
-               throw PosixException("gettimeofday() failed", errno);
+               throw_exception(PosixException("gettimeofday() failed", errno));
 
        return tv.tv_sec + tv.tv_usec / 1000000.0;
 #endif /* _WIN32 */