dbus: util: add missing try/catch block
Add missing try/catch block to getProperties.
Change-Id: Ie1f08f496dc529432df620879416e8bddb2e7d5c
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/dbus/util.cpp b/dbus/util.cpp
index 23f06fd..3e3597b 100644
--- a/dbus/util.cpp
+++ b/dbus/util.cpp
@@ -58,12 +58,19 @@
propertiesintf.c_str(), "GetAll");
pimMsg.append(sensorintf);
- auto valueResponseMsg = bus.call(pimMsg);
- if (valueResponseMsg.is_method_error())
+ PropertyMap propMap;
+
+ try
{
- std::cerr << "Error in value call\n";
- throw std::runtime_error("ERROR in value call.");
+ auto valueResponseMsg = bus.call(pimMsg);
+ valueResponseMsg.read(propMap);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ log<level::ERR>("GetAll Properties Failed",
+ entry("WHAT=%s", ex.what()));
+ throw;
}
// The PropertyMap returned will look like this because it's always
@@ -72,8 +79,6 @@
// "Value" x 24875
// "Unit" s "xyz.openbmc_project.Sensor.Value.Unit.DegreesC"
// "Scale" x -3
- PropertyMap propMap;
- valueResponseMsg.read(propMap);
// If no error was set, the values should all be there.
auto findUnit = propMap.find("Unit");