fs/io/FileOutputStream: use C++ exceptions in Commit()

This commit is contained in:
Max Kellermann
2015-12-16 00:24:41 +01:00
parent 24b2198668
commit 7eae3bc8c5
8 changed files with 61 additions and 44 deletions

View File

@@ -244,8 +244,14 @@ RecorderOutput::Commit(Error &error)
encoder->Close();
if (success && !file->Commit(error))
success = false;
if (success) {
try {
file->Commit();
} catch (...) {
delete file;
throw;
}
}
delete file;
@@ -263,9 +269,13 @@ RecorderOutput::Close()
return;
}
Error error;
if (!Commit(error))
LogError(error);
try {
Error error;
if (!Commit(error))
LogError(error);
} catch (const std::exception &e) {
LogError(e);
}
if (HasDynamicPath()) {
assert(!path.IsNull());
@@ -281,9 +291,13 @@ RecorderOutput::FinishFormat()
if (file == nullptr)
return;
Error error;
if (!Commit(error))
LogError(error);
try {
Error error;
if (!Commit(error))
LogError(error);
} catch (const std::exception &e) {
LogError(e);
}
file = nullptr;
path.SetNull();