dbusUtils: add try catch to catch error when getDbusProperty failed
Avoid to getDbusProperty fail, when sensor service is broken after
sensor propertiesChanged signal be triggered. And then return NaN.
Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: Ibd73eb27cfd6274ab56ea7d74db98fdd7d7c1734
diff --git a/dbusUtils.hpp b/dbusUtils.hpp
index 93898a3..f718e6d 100644
--- a/dbusUtils.hpp
+++ b/dbusUtils.hpp
@@ -67,8 +67,15 @@
method.append(intf, property);
- auto msg = bus.call(method);
- msg.read(value);
+ try
+ {
+ auto msg = bus.call(method);
+ msg.read(value);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ return std::numeric_limits<T>::quiet_NaN();
+ }
return std::get<T>(value);
}