diff options
| author | Patrick Venture <venture@google.com> | 2018-09-06 17:56:41 -0700 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2018-09-06 18:02:37 -0700 |
| commit | acecf6b82c5dfbcab9215936eb1ee5fd3893a32d (patch) | |
| tree | c562b43d2474dbf896d2187683a6b0ab44f27ae7 /ipmi | |
| parent | e2ec0f618a9b3b6809a98516abe63d5d833e7fe7 (diff) | |
| download | phosphor-pid-control-acecf6b82c5dfbcab9215936eb1ee5fd3893a32d.tar.gz phosphor-pid-control-acecf6b82c5dfbcab9215936eb1ee5fd3893a32d.zip | |
ipmi: catch SdBusErrors on bus call failures
Now sdbusplus call and call_noreply can throw an SdBusError exception.
This code changes from checking .is_method_error() to catching the
exception.
Issue: 4
Change-Id: I07bbe5dbbd91d72ca75eeb14861d56aae5f3afed
Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'ipmi')
| -rw-r--r-- | ipmi/manualcmds.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/ipmi/manualcmds.cpp b/ipmi/manualcmds.cpp index eabcd0a..798deab 100644 --- a/ipmi/manualcmds.cpp +++ b/ipmi/manualcmds.cpp @@ -84,22 +84,20 @@ static ipmi_ret_t GetFanCtrlProperty(uint8_t zoneId, bool* value, propertiesintf, "GetAll"); pimMsg.append(intf); - auto valueResponseMsg = propertyReadBus.call(pimMsg); - if (valueResponseMsg.is_method_error()) + try { - return IPMI_CC_INVALID; - } + auto valueResponseMsg = propertyReadBus.call(pimMsg); - PropertyMap propMap; - valueResponseMsg.read(propMap); + PropertyMap propMap; + valueResponseMsg.read(propMap); - if (propMap.size() != 2) + *value = sdbusplus::message::variant_ns::get<bool>(propMap[property]); + } + catch (const sdbusplus::exception::SdBusError& ex) { return IPMI_CC_INVALID; } - *value = sdbusplus::message::variant_ns::get<bool>(propMap[property]); - return IPMI_CC_OK; } @@ -193,8 +191,12 @@ static ipmi_ret_t SetManualModeState(const uint8_t* reqBuf, uint8_t* replyBuf, pimMsg.append(intf); pimMsg.append(manualProperty); pimMsg.append(v); - auto responseMsg = PropertyWriteBus.call(pimMsg); - if (responseMsg.is_method_error()) + + try + { + PropertyWriteBus.call_noreply(pimMsg); + } + catch (const sdbusplus::exception::SdBusError& ex) { rc = IPMI_CC_INVALID; } |

