summaryrefslogtreecommitdiff
path: root/src/StateFile.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-12-15 22:26:26 +0100
committerMax Kellermann <max@duempel.org>2015-12-16 00:33:30 +0100
commit24b2198668ad5d0b3f965bc34762bfac4004bcf2 (patch)
treee1879d21e84d9f59cb0fc0eeda29bdfeb3105ce4 /src/StateFile.cxx
parentd29be0f46099417f9148189ce33b3772b7849c9c (diff)
fs/io/FileOutputStream: use C++ exceptions in constructor
Diffstat (limited to 'src/StateFile.cxx')
-rw-r--r--src/StateFile.cxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/StateFile.cxx b/src/StateFile.cxx
index ebf6cf576..8d17a1827 100644
--- a/src/StateFile.cxx
+++ b/src/StateFile.cxx
@@ -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();