summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2019-06-10 14:55:17 +0800
committerLei YU <mine260309@gmail.com>2019-06-11 17:49:33 +0800
commitc08cf5283b80a071d19506d9a462f6c69e1797f1 (patch)
tree0cb65982f576f4fa31486e240d5f6a75a3439631
parentc14699f63e909ed6d8599e65503ee9c1e3a104d6 (diff)
downloadsdbusplus-c08cf5283b80a071d19506d9a462f6c69e1797f1.tar.gz
sdbusplus-c08cf5283b80a071d19506d9a462f6c69e1797f1.zip
message: Add get_error()
Add message::get_error() to get sd_bus_error from a message. Tested: Verify the function is added, the build passes, and the user of sdbusplus is able to call message::get_error() to get the const sd_bus_error* pointer. Change-Id: If4c413316ff7654448e9da19adcd3dab2c33675e Signed-off-by: Lei YU <mine260309@gmail.com>
-rw-r--r--sdbusplus/message.hpp9
-rw-r--r--sdbusplus/sdbus.hpp6
-rw-r--r--sdbusplus/test/sdbus_mock.hpp2
3 files changed, 17 insertions, 0 deletions
diff --git a/sdbusplus/message.hpp b/sdbusplus/message.hpp
index a307a6f..b56921b 100644
--- a/sdbusplus/message.hpp
+++ b/sdbusplus/message.hpp
@@ -219,6 +219,15 @@ class message
return _intf->sd_bus_message_get_errno(_msg.get());
}
+ /** @brief Get the error from the message.
+ *
+ * @return The error of the message.
+ */
+ const sd_bus_error* get_error()
+ {
+ return _intf->sd_bus_message_get_error(_msg.get());
+ }
+
/** @brief Get the type of a message.
*
* @return The type of message.
diff --git a/sdbusplus/sdbus.hpp b/sdbusplus/sdbus.hpp
index bd42033..5a73309 100644
--- a/sdbusplus/sdbus.hpp
+++ b/sdbusplus/sdbus.hpp
@@ -91,6 +91,7 @@ class SdBusInterface
virtual const char* sd_bus_message_get_signature(sd_bus_message* m,
int complete) = 0;
virtual int sd_bus_message_get_errno(sd_bus_message* m) = 0;
+ virtual const sd_bus_error* sd_bus_message_get_error(sd_bus_message* m) = 0;
virtual int sd_bus_message_is_method_call(sd_bus_message* m,
const char* interface,
@@ -359,6 +360,11 @@ class SdBusImpl : public SdBusInterface
return ::sd_bus_message_get_errno(m);
}
+ const sd_bus_error* sd_bus_message_get_error(sd_bus_message* m) override
+ {
+ return ::sd_bus_message_get_error(m);
+ }
+
int sd_bus_message_is_method_call(sd_bus_message* m, const char* interface,
const char* member) override
{
diff --git a/sdbusplus/test/sdbus_mock.hpp b/sdbusplus/test/sdbus_mock.hpp
index 36a8598..b88b120 100644
--- a/sdbusplus/test/sdbus_mock.hpp
+++ b/sdbusplus/test/sdbus_mock.hpp
@@ -68,6 +68,8 @@ class SdBusMock : public SdBusInterface
MOCK_METHOD2(sd_bus_message_get_signature,
const char*(sd_bus_message*, int));
MOCK_METHOD1(sd_bus_message_get_errno, int(sd_bus_message*));
+ MOCK_METHOD1(sd_bus_message_get_error,
+ const sd_bus_error*(sd_bus_message*));
MOCK_METHOD3(sd_bus_message_is_method_call,
int(sd_bus_message*, const char*, const char*));
OpenPOWER on IntegriCloud