Use proper errors when failing to set time

Previously it reports InsufficientPermission when it is not allowed to
set time.

Now phosphor-dbus-interfaces defines proper errors for such case, so
report NotAllowed error when it is not allowed to set time, and report
Failed error when it failed to set time.

Tested: Get NotAllowed and Failed error with expected metadata from
        journal log.

Change-Id: I53610bf27ffc3f62608cea6fd0e66ca859d94675
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/epoch_base.cpp b/epoch_base.cpp
index bab5d3b..e130578 100644
--- a/epoch_base.cpp
+++ b/epoch_base.cpp
@@ -1,6 +1,9 @@
 #include "epoch_base.hpp"
 
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <xyz/openbmc_project/Time/error.hpp>
 
 #include <iomanip>
 #include <sstream>
@@ -19,6 +22,8 @@
 {
 
 using namespace phosphor::logging;
+using FailedError =
+    sdbusplus::xyz::openbmc_project::Time::Error::Failed;
 
 EpochBase::EpochBase(sdbusplus::bus::bus& bus,
                      const char* objPath)
@@ -50,10 +55,10 @@
     auto reply = bus.call(method);
     if (reply.is_method_error())
     {
-        // TODO: When sdbus supports exception on property
-        // it can just throw exception instead of returning bool
         log<level::ERR>("Error in setting system time");
-        return false;
+        using namespace xyz::openbmc_project::Time;
+        elog<FailedError>(
+            Failed::REASON("Systemd failed to set time"));
     }
     return true;
 }