mirror of https://github.com/Icinga/icinga2.git
Cleaned up exception handling.
This commit is contained in:
parent
e3661898ea
commit
a9610ecb9e
|
@ -39,7 +39,7 @@ DynamicObject::DynamicObject(const Dictionary::Ptr& serializedObject)
|
||||||
RegisterAttribute("methods", Attribute_Config);
|
RegisterAttribute("methods", Attribute_Config);
|
||||||
|
|
||||||
if (!serializedObject->Contains("configTx"))
|
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;
|
/* apply config state from the config item/remote update;
|
||||||
* The DynamicObject::Create function takes care of restoring
|
* 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)
|
void DynamicObject::RestoreObjects(const String& filename)
|
||||||
|
|
|
@ -104,7 +104,8 @@ void Object::PrintMemoryProfile(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
dictfp.close();
|
dictfp.close();
|
||||||
rename("dictionaries.dump.tmp", "dictionaries.dump");
|
if (rename("dictionaries.dump.tmp", "dictionaries.dump") < 0)
|
||||||
|
throw_exception(PosixException("rename() failed", errno));
|
||||||
|
|
||||||
String type;
|
String type;
|
||||||
int count;
|
int count;
|
||||||
|
|
|
@ -284,7 +284,7 @@ double Utility::GetTime(void)
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
if (gettimeofday(&tv, NULL) < 0)
|
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;
|
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
Loading…
Reference in New Issue