fs/io/FileOutputStream: use C++ exceptions in constructor

This commit is contained in:
Max Kellermann
2015-12-15 22:26:26 +01:00
parent d29be0f460
commit 24b2198668
9 changed files with 64 additions and 72 deletions

View File

@@ -32,6 +32,8 @@
#include "util/Domain.hxx"
#include "Log.hxx"
#include <exception>
#include <string.h>
static constexpr Domain state_file_domain("state_file");
@@ -87,11 +89,15 @@ StateFile::Write()
FormatDebug(state_file_domain,
"Saving state file %s", path_utf8.c_str());
Error error;
FileOutputStream fos(path, error);
if (!fos.IsDefined() || !Write(fos, error) || !fos.Commit(error)) {
LogError(error);
return;
try {
Error error;
FileOutputStream fos(path);
if (!Write(fos, error) || !fos.Commit(error)) {
LogError(error);
return;
}
} catch (const std::exception &e) {
LogError(e);
}
RememberVersions();