add try-catch when call setAttention method
Currently, users can use btbridge/ssifbridge/kcsbridge to interact BMC
and HOST. But only btbridge define "org.openbmc.HostIpmi", therefore, if
the platform does not use btbridge, host-ipmid will throw an exception
when try to check the status of HOST when call setAttention method.
This commit adds the try-catch to make platform still work moothly when
uses ssifbridge/kcsbridge.
Tested:
1. Use ssifbridge to interact BMC and HOST.
2. Check Host condition.
busctl introspect xyz.openbmc_project.Control.Host \
/xyz/openbmc_project/control/host0
3. Display information of "/xyz/openbmc_project/control/host0"
Signed-off-by: Thang Tran <thuutran@amperecomputing.com>
Change-Id: I63e584c1f89c6b31de4fa66beb3f0e0b6bdf5e0f
diff --git a/host-cmd-manager.cpp b/host-cmd-manager.cpp
index e52c9bb..b3aeb5a 100644
--- a/host-cmd-manager.cpp
+++ b/host-cmd-manager.cpp
@@ -130,14 +130,17 @@
auto method =
this->bus.new_method_call(HOST_IPMI_SVC.c_str(), IPMI_PATH.c_str(),
IPMI_INTERFACE.c_str(), "setAttention");
- auto reply = this->bus.call(method);
- if (reply.is_method_error())
+ try
{
- log<level::ERR>("Error in setting SMS attention");
- elog<InternalFailure>();
+ auto reply = this->bus.call(method);
+
+ log<level::DEBUG>("SMS Attention asserted");
}
- log<level::DEBUG>("SMS Attention asserted");
+ catch (sdbusplus::exception::exception& e)
+ {
+ log<level::ERR>("Error when call setAttention method");
+ }
}
}