diff options
author | Lei YU <mine260309@gmail.com> | 2019-06-11 12:44:27 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2019-06-14 18:59:53 +0300 |
commit | 97d2a47ddc8f11f796e4f4eba48423a8fba732c2 (patch) | |
tree | 8c68f077113de65a14a2d5fea2d4254ef1413e62 /include | |
parent | cee58b238fefd7ba49c55989cc5e0ece97c6509d (diff) | |
download | bmcweb-97d2a47ddc8f11f796e4f4eba48423a8fba732c2.tar.xz |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/openbmc_dbus_rest.hpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index af6451de2a..398612f75a 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 { |