summaryrefslogtreecommitdiffstats
path: root/writefrudata.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-16 19:17:41 -0700
committerPatrick Venture <venture@google.com>2018-10-17 10:50:49 -0700
commit5739ac3b37ffa3fc32664afdd5aa9ef8f5cf2aa0 (patch)
tree9b76025b3714f38ead50fba32be6a970dea1d0fd /writefrudata.cpp
parentd57cd016d8d531732d6943d6e1434ef1862607a0 (diff)
downloadipmi-fru-parser-5739ac3b37ffa3fc32664afdd5aa9ef8f5cf2aa0.tar.gz
ipmi-fru-parser-5739ac3b37ffa3fc32664afdd5aa9ef8f5cf2aa0.zip
writefrudata: catch exceptions in sdbusplus call
Catch sdbusplus call exceptions. Change-Id: Iff0b2a4265061c90ebac78f90e4183f5e36037ef Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'writefrudata.cpp')
-rw-r--r--writefrudata.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 371fa6c..2bbf48e 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -16,11 +16,13 @@
#include <fstream>
#include <iostream>
#include <memory>
+#include <phosphor-logging/log.hpp>
#include <sdbusplus/server.hpp>
#include <sstream>
#include <vector>
using namespace ipmi::vpd;
+using namespace phosphor::logging;
extern const FruMap frus;
extern const std::map<Path, InterfaceMap> extras;
@@ -265,15 +267,19 @@ auto getService(sdbusplus::bus::bus& bus, const std::string& intf,
mapperCall.append(path);
mapperCall.append(std::vector<std::string>({intf}));
+ std::map<std::string, std::vector<std::string>> mapperResponse;
- auto mapperResponseMsg = bus.call(mapperCall);
- if (mapperResponseMsg.is_method_error())
+ try
{
- throw std::runtime_error("ERROR in mapper call");
+ auto mapperResponseMsg = bus.call(mapperCall);
+ mapperResponseMsg.read(mapperResponse);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ log<level::ERR>("Exception from sdbus call",
+ entry("WHAT=%s", ex.what()));
+ throw;
}
-
- std::map<std::string, std::vector<std::string>> mapperResponse;
- mapperResponseMsg.read(mapperResponse);
if (mapperResponse.begin() == mapperResponse.end())
{
@@ -325,7 +331,7 @@ int ipmi_update_inventory(fru_area_vec_t& area_vec, sd_bus* bus_sd)
{
service = getService(bus, intf, path);
}
- catch (const std::runtime_error& e)
+ catch (const std::exception& e)
{
std::cerr << e.what() << "\n";
return -1;
@@ -403,12 +409,17 @@ int ipmi_update_inventory(fru_area_vec_t& area_vec, sd_bus* bus_sd)
auto pimMsg = bus.new_method_call(service.c_str(), path.c_str(),
intf.c_str(), "Notify");
pimMsg.append(std::move(objects));
- auto inventoryMgrResponseMsg = bus.call(pimMsg);
- if (inventoryMgrResponseMsg.is_method_error())
+
+ try
{
- std::cerr << "Error in notify call\n";
+ auto inventoryMgrResponseMsg = bus.call(pimMsg);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ log<level::ERR>("Error in notify call", entry("WHAT=%s", ex.what()));
return -1;
}
+
return rc;
}
OpenPOWER on IntegriCloud