summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2018-07-24 10:09:35 +0800
committerLei YU <mine260309@gmail.com>2018-09-12 10:45:04 +0800
commitbae8d7a532521c1aeb558db65d903999fa76489d (patch)
treef1e40cd465a1a5c0d3f269d234a4f7a8d5d86a36
parentf6fad82032fa2f43378294d3f5a860343f5d771b (diff)
downloadphosphor-time-manager-bae8d7a532521c1aeb558db65d903999fa76489d.tar.gz
phosphor-time-manager-bae8d7a532521c1aeb558db65d903999fa76489d.zip
Handle SdBusError exception in setting time
sdbusplus now throws SdBusError exception when a sd bus call fails. When setting time via systemd timedatectl service, it may fail to set time due to time settings. So handle this exception and print the reason. Tested: Verify this service does not crash but prints the exception in journal log, when it fails to set time to systemd. Change-Id: I7d3b2e35e58c3924f95d3664653e68efbae8bd14 Signed-off-by: Lei YU <mine260309@gmail.com>
-rw-r--r--epoch_base.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/epoch_base.cpp b/epoch_base.cpp
index e130578..8aa41dd 100644
--- a/epoch_base.cpp
+++ b/epoch_base.cpp
@@ -52,13 +52,17 @@ bool EpochBase::setTime(const microseconds& usec)
method.append(static_cast<int64_t>(usec.count()),
false, // relative
false); // user_interaction
- auto reply = bus.call(method);
- if (reply.is_method_error())
+
+ try
+ {
+ bus.call_noreply(method);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
{
log<level::ERR>("Error in setting system time");
using namespace xyz::openbmc_project::Time;
elog<FailedError>(
- Failed::REASON("Systemd failed to set time"));
+ Failed::REASON(ex.what()));
}
return true;
}
OpenPOWER on IntegriCloud