Throw excpetion when it is not allowed to set time

When it is not allowed to set time depending on the time setting,
previously we only log an error and continue.
Now sdbusplus supports errors on properties, so we can throw exception
on such case.

Tested: Verify in unittest that exception is thrown when it is not
        allowed to set time.
        Verify in BMC that busctl gets the error message when it is not
        allowed to set time.
Change-Id: I4a04d1aa8c081abf0f9fd449118dc1107e12f689
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/test/TestBmcEpoch.cpp b/test/TestBmcEpoch.cpp
index 32592e6..2d0bc72 100644
--- a/test/TestBmcEpoch.cpp
+++ b/test/TestBmcEpoch.cpp
@@ -1,12 +1,13 @@
-#include <sdbusplus/bus.hpp>
-#include <gtest/gtest.h>
-#include <memory>
-
 #include "bmc_epoch.hpp"
 #include "config.h"
 #include "types.hpp"
 #include "mocked_bmc_time_change_listener.hpp"
 
+#include <gtest/gtest.h>
+#include <memory>
+#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
 namespace phosphor
 {
 namespace time
@@ -14,6 +15,8 @@
 
 using ::testing::_;
 using namespace std::chrono;
+using InsufficientPermission =
+    sdbusplus::xyz::openbmc_project::Common::Error::InsufficientPermission;
 
 class TestBmcEpoch : public testing::Test
 {
@@ -88,8 +91,9 @@
     // In Host owner, setting time is not allowed
     setTimeMode(Mode::Manual);
     setTimeOwner(Owner::Host);
-    auto ret = bmcEpoch->elapsed(epochNow);
-    EXPECT_EQ(0, ret);
+    EXPECT_THROW(
+        bmcEpoch->elapsed(epochNow),
+        InsufficientPermission);
 }
 
 TEST_F(TestBmcEpoch, setElapsedOK)