phosphor-dump-manager: Fix for deserialize cereal exception

This commit provides a fix for an issue in which the cereal
deserialize() would crash the phosphor-dump-manager incase
persistence file is empty in restore path.

Change-Id: I25259acf50f67cbc8d7b7ac3030bd7bfffbdfa47
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/dump_serialize.cpp b/dump_serialize.cpp
index 26990a0..13a8b7e 100644
--- a/dump_serialize.cpp
+++ b/dump_serialize.cpp
@@ -2,6 +2,8 @@
 #include <cereal/archives/binary.hpp>
 #include <fstream>
 
+#include <phosphor-logging/log.hpp>
+
 #include "dump_serialize.hpp"
 
 namespace phosphor
@@ -11,6 +13,8 @@
 namespace elog
 {
 
+using namespace phosphor::logging;
+
 void serialize(const ElogList& list, const fs::path& dir)
 {
     std::ofstream os(dir.c_str(), std::ios::binary);
@@ -20,14 +24,23 @@
 
 bool deserialize(const fs::path& path, ElogList& list)
 {
-    if (fs::exists(path))
+    try
     {
-        std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
-        cereal::BinaryInputArchive iarchive(is);
-        iarchive(list);
-        return true;
+        if (fs::exists(path))
+        {
+            std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
+            cereal::BinaryInputArchive iarchive(is);
+            iarchive(list);
+            return true;
+        }
+        return false;
     }
-    return false;
+    catch(cereal::Exception& e)
+    {
+        log<level::ERR>(e.what());
+        fs::remove(path);
+        return false;
+    }
 }
 
 } // namespace elog