summaryrefslogtreecommitdiffstats
path: root/elog_serialize.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'elog_serialize.cpp')
-rw-r--r--elog_serialize.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/elog_serialize.cpp b/elog_serialize.cpp
index 72dc295..f8c40e1 100644
--- a/elog_serialize.cpp
+++ b/elog_serialize.cpp
@@ -3,7 +3,9 @@
#include <cereal/types/tuple.hpp>
#include <cereal/archives/binary.hpp>
#include <fstream>
+
#include "elog_serialize.hpp"
+#include <phosphor-logging/log.hpp>
namespace phosphor
{
@@ -65,14 +67,23 @@ fs::path serialize(const Entry& e, const fs::path& dir)
bool deserialize(const fs::path& path, Entry& e)
{
- if (fs::exists(path))
+ try
+ {
+ if (fs::exists(path))
+ {
+ std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
+ cereal::BinaryInputArchive iarchive(is);
+ iarchive(e);
+ return true;
+ }
+ return false;
+ }
+ catch(cereal::Exception& e)
{
- std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
- cereal::BinaryInputArchive iarchive(is);
- iarchive(e);
- return true;
+ log<level::ERR>(e.what());
+ fs::remove(path);
+ return false;
}
- return false;
}
} // namespace logging
OpenPOWER on IntegriCloud