commit | 3e3cc35bd2d2efeee76bafc406d76bdef87c20b6 | [log] [tgz] |
---|---|---|
author | George Liu <liuxiwei@inspur.com> | Wed Jul 26 15:59:31 2023 +0800 |
committer | George Liu <liuxiwei@inspur.com> | Wed Aug 02 14:41:26 2023 +0800 |
tree | 654cdc1abfc13c1743f0c5a026a7b6708fd74bf9 | |
parent | efb4f6aa876787aaa9d0fed415dfe7e4d114307c [diff] [blame] |
Remove is_method_error method Remove the usage of is_method_error()[1], and add try-catch to handle D-Bus exceptions around mapper call. [1]https://github.com/openbmc/sdbusplus/commit/079fb85a398d90800935e3985bb1266a7530a26e#diff-945669e8bd9cab4ecc83a574a732921281b2c79eb8bba65efff11736ad18f92bR237-R240 Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I85192219c1c34cf5fd6c6aca06a8b207d7e06697
diff --git a/softoff/softoff.cpp b/softoff/softoff.cpp index 0c2c9bd..7dcde4c 100644 --- a/softoff/softoff.cpp +++ b/softoff/softoff.cpp
@@ -41,16 +41,17 @@ CONTROL_HOST_BUSNAME, "Execute"); method.append(convertForMessage(Host::Command::SoftOff).c_str()); - - auto reply = bus.call(method); - if (reply.is_method_error()) + try { - log<level::ERR>("Error in call to control host Execute"); + auto reply = bus.call(method); + } + catch (const std::exception& e) + { + log<level::ERR>("Error in call to control host Execute", + entry("ERROR=%s", e.what())); // TODO openbmc/openbmc#851 - Once available, throw returned error throw std::runtime_error("Error in call to control host Execute"); } - - return; } // Function called on host control signals