diff options
| author | Patrick Venture <venture@google.com> | 2018-10-30 12:18:45 -0700 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2018-10-30 13:46:54 -0700 |
| commit | 7dbc517382bd3c2c5b60635958c18de8f1f39b4e (patch) | |
| tree | bb46f30ff4f8b828acfc4878e1113e632288e882 | |
| parent | ee30648efa42d25979894082b5e300fdb192f3a2 (diff) | |
| download | phosphor-pid-control-7dbc517382bd3c2c5b60635958c18de8f1f39b4e.tar.gz phosphor-pid-control-7dbc517382bd3c2c5b60635958c18de8f1f39b4e.zip | |
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>
| -rw-r--r-- | dbus/util.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
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 @@ void DbusHelper::getProperties(sdbusplus::bus::bus& bus, 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 @@ void DbusHelper::getProperties(sdbusplus::bus::bus& bus, // "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"); |

