diff options
| author | William A. Kennington III <wak@google.com> | 2018-10-03 14:47:46 -0700 |
|---|---|---|
| committer | William A. Kennington III <wak@google.com> | 2018-10-05 21:15:10 +0000 |
| commit | 20adbc2d459123772ecd2d17009e1db0dd6314f2 (patch) | |
| tree | 860107701afafd0af41d30eb8be7d209dc6ca8ee | |
| parent | 2b74e528cbe1b12c2e6d2757af87696d5029f8af (diff) | |
| download | sdbusplus-20adbc2d459123772ecd2d17009e1db0dd6314f2.tar.gz sdbusplus-20adbc2d459123772ecd2d17009e1db0dd6314f2.zip | |
message: Add error handling
Some of the methods that can return errors are not being checked for
errors. Check all of the return values where necessary.
Tested:
Ran through a build and unit test run
Change-Id: I3f8469cbe80a0c58032407f2ba184d913df6e2f1
Signed-off-by: William A. Kennington III <wak@google.com>
| -rw-r--r-- | sdbusplus/message.hpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sdbusplus/message.hpp b/sdbusplus/message.hpp index eb2d49d..30e8d8a 100644 --- a/sdbusplus/message.hpp +++ b/sdbusplus/message.hpp @@ -226,7 +226,11 @@ class message auto get_cookie() { uint64_t cookie; - _intf->sd_bus_message_get_cookie(_msg.get(), &cookie); + int r = _intf->sd_bus_message_get_cookie(_msg.get(), &cookie); + if (r < 0) + { + throw exception::SdBusError(-r, "sd_bus_message_get_cookie"); + } return cookie; } @@ -260,7 +264,11 @@ class message message new_method_return() { msgp_t reply = nullptr; - _intf->sd_bus_message_new_method_return(this->get(), &reply); + int r = _intf->sd_bus_message_new_method_return(this->get(), &reply); + if (r < 0) + { + throw exception::SdBusError(-r, "sd_bus_message_new_method_return"); + } return message(reply, std::false_type()); } @@ -287,7 +295,11 @@ class message void method_return() { auto b = _intf->sd_bus_message_get_bus(this->get()); - _intf->sd_bus_send(b, this->get(), nullptr); + int r = _intf->sd_bus_send(b, this->get(), nullptr); + if (r < 0) + { + throw exception::SdBusError(-r, "sd_bus_send"); + } } /** @brief Perform a 'signal-send' call. */ |

