REST: PUT: return DBus error description
The boost::system::error_code returned by the DBus call will contain the
DBus error name and description in its error_category, use the
category's name and message as REST API's description and message.
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: I90c11c0fc61e55329c809ecb5f948ae041a579d0
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 6938079..af6451d 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -1871,7 +1871,8 @@
boost::beast::http::
status::
forbidden,
- forbiddenPropDesc,
+ ec.category()
+ .name(),
ec.message());
}
else