Make D-bus systemd error handling consistent
Make consistent with the extra error handling added to the
chassis_state_manager.cpp code
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I144a692a0472b1db9b45dc14444dd39081c7387a
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index 7d661dd..425e5c8 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -36,6 +36,7 @@
using namespace phosphor::logging;
namespace fs = std::experimental::filesystem;
using sdbusplus::exception::SdBusError;
+using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
// host-shutdown notifies host of shutdown and that leads to host-stop being
// called so initiate a host shutdown with the -shutdown target and consider the
@@ -77,8 +78,16 @@
{
auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
SYSTEMD_INTERFACE, "Subscribe");
- this->bus.call_noreply(method);
-
+ try
+ {
+ this->bus.call_noreply(method);
+ }
+ catch (const SdBusError& e)
+ {
+ log<level::ERR>("Failed to subscribe to systemd signals",
+ entry("ERR=%s", e.what()));
+ elog<InternalFailure>();
+ }
return;
}