summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2019-06-11 17:44:27 +0800
committerEd Tanous <ed.tanous@intel.com>2019-06-14 15:59:53 +0000
commit97d2a47ddc8f11f796e4f4eba48423a8fba732c2 (patch)
tree8c68f077113de65a14a2d5fea2d4254ef1413e62
parentcee58b238fefd7ba49c55989cc5e0ece97c6509d (diff)
downloadbmcweb-97d2a47ddc8f11f796e4f4eba48423a8fba732c2.tar.gz
bmcweb-97d2a47ddc8f11f796e4f4eba48423a8fba732c2.zip
REST: PUT: return DBus error description
sdbusplus adds message::get_error() to provide the actual sd_bus_error of a message. With this, return the error's name and message in REST API so that the correct error is returned to end user. Tested: Verify the REST API output when trying to set host time while the settings does not allow that: $ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PUT -d '{"data": 1436655598435272}' https://$bmc/xyz/openbmc_project/time/bmc/attr/Elapsed { "data": { "description": "xyz.openbmc_project.Time.Error.NotAllowed" }, "message": "The operation is not allowed", "status": "error" } Resolves openbmc/bmcweb#83 Change-Id: I0bd5405c6748d124f9dd8a341e29f3918445158e Signed-off-by: Lei YU <mine260309@gmail.com>
-rw-r--r--CMakeLists.txt.in2
-rw-r--r--include/openbmc_dbus_rest.hpp7
2 files changed, 5 insertions, 4 deletions
diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in
index 02a1104..06b9cfb 100644
--- a/CMakeLists.txt.in
+++ b/CMakeLists.txt.in
@@ -9,7 +9,7 @@ file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/prefix/include)
externalproject_add (
sdbusplus-project PREFIX ${CMAKE_BINARY_DIR}/sdbusplus-project
GIT_REPOSITORY https://github.com/openbmc/sdbusplus.git GIT_TAG
- 8cd7a4a10c02a450bc21580a4bde34328a841d13 SOURCE_DIR
+ c08cf5283b80a071d19506d9a462f6c69e1797f1 SOURCE_DIR
${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR
${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND "" BUILD_COMMAND cd
${CMAKE_BINARY_DIR}/sdbusplus-src && ./bootstrap.sh && ./configure
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index af6451d..398612f 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -1866,14 +1866,15 @@ void handlePut(const crow::Request &req, crow::Response &res,
BMCWEB_LOG_DEBUG << "sent";
if (ec)
{
+ const sd_bus_error *e =
+ m.get_error();
setErrorResponse(
transaction->res,
boost::beast::http::
status::
forbidden,
- ec.category()
- .name(),
- ec.message());
+ e->name,
+ e->message);
}
else
{
OpenPOWER on IntegriCloud