summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2018-07-24 10:38:01 +0800
committerLei YU <mine260309@gmail.com>2018-09-12 10:45:04 +0800
commit89efe6ed27a9df5a8e761073bdadd3fdd3fa5875 (patch)
tree4084705d09f5980233cd06a113ca1e402dbaac2b
parentbae8d7a532521c1aeb558db65d903999fa76489d (diff)
downloadphosphor-time-manager-89efe6ed27a9df5a8e761073bdadd3fdd3fa5875.tar.gz
phosphor-time-manager-89efe6ed27a9df5a8e761073bdadd3fdd3fa5875.zip
Handle SdBusError exception in setting NTP
sdbusplus now throws SdBusError exception when a sd bus call fails. When setting NTP via systemd timedatectl service, it may potentially fail. So handle this exception. Also fix a typo in logging, where it should use `=` in meta. Change-Id: I6c5669b7f06cef47c8d62cb0cbcb0c7fbd2a46e7 Tested: Verify it sets NTP setting OK.
-rw-r--r--manager.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/manager.cpp b/manager.cpp
index 1145d33..8d3d955 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -194,14 +194,16 @@ void Manager::updateNtpSetting(const std::string& value)
method.append(isNtp, false); // isNtp: 'true/false' means Enable/Disable
// 'false' meaning no policy-kit
- if (bus.call(method))
+ try
{
+ bus.call_noreply(method);
log<level::INFO>("Updated NTP setting",
- entry("ENABLED:%d", isNtp));
+ entry("ENABLED=%d", isNtp));
}
- else
+ catch (const sdbusplus::exception::SdBusError& ex)
{
- log<level::ERR>("Failed to update NTP setting");
+ log<level::ERR>("Failed to update NTP setting",
+ entry("ERR=%s", ex.what()));
}
}
OpenPOWER on IntegriCloud