From a9610ecb9ef0d3b4b252fafa489b88c7bfe262d3 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 14 Aug 2012 09:51:11 +0200 Subject: [PATCH] Cleaned up exception handling. --- base/dynamicobject.cpp | 5 +++-- base/object.cpp | 3 ++- base/utility.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/base/dynamicobject.cpp b/base/dynamicobject.cpp index f9be99193..13d82081d 100644 --- a/base/dynamicobject.cpp +++ b/base/dynamicobject.cpp @@ -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) diff --git a/base/object.cpp b/base/object.cpp index 846912f6a..da68ed0fa 100644 --- a/base/object.cpp +++ b/base/object.cpp @@ -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; diff --git a/base/utility.cpp b/base/utility.cpp index 79ae91ad8..710655d90 100644 --- a/base/utility.cpp +++ b/base/utility.cpp @@ -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 */ -- 2.40.0