summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-06-19 00:09:25 +0300
committerMatt Spinler <spinler@us.ibm.com>2019-06-20 22:08:05 +0300
commit06b1b63c3cc85b5b77521e7fed0b2a23a63bfbb6 (patch)
tree50eae791f07be33865a79d194bd6ce007a865dbf /include
parent961c9d9cb05b8da1e4fa8f8e04872dad3b234879 (diff)
downloadbmcweb-06b1b63c3cc85b5b77521e7fed0b2a23a63bfbb6.tar.xz
REST: method call: return D-Bus error desc
When invoking a D-Bus method call via the 'action' URL, return the error that came back from the D-Bus call as opposed to just hardcoding one. Tested: A POST on /xyz/openbmc_project/dump/action/CreateDump when no more dumps can be created now returns: { "data": { "description": "xyz.openbmc_project.Dump.Create.Error.QuotaExceeded" }, "message": "Dump not captured due to a cap.", "status": "error" } Change-Id: Ifd0c97f82ff05842fa0f36ef3bb1aaba42ad7d49 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/openbmc_dbus_rest.hpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index cfbe4cb109..0aa23e22cc 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -415,13 +415,7 @@ struct InProgressActionData
{
if (!methodPassed)
{
- if (methodFailed)
- {
- setErrorResponse(res,
- boost::beast::http::status::bad_request,
- "Method call failed", methodFailedMsg);
- }
- else
+ if (!methodFailed)
{
setErrorResponse(res, boost::beast::http::status::not_found,
methodNotFoundDesc, notFoundMsg);
@@ -1388,6 +1382,25 @@ void findActionOnInterface(std::shared_ptr<InProgressActionData> transaction,
if (ec)
{
transaction->methodFailed = true;
+ const sd_bus_error *e = m.get_error();
+
+ if (e)
+ {
+ setErrorResponse(
+ transaction->res,
+ boost::beast::http::status::
+ bad_request,
+ e->name, e->message);
+ }
+ else
+ {
+ setErrorResponse(
+ transaction->res,
+ boost::beast::http::status::
+ bad_request,
+ "Method call failed",
+ methodFailedMsg);
+ }
return;
}
else
@@ -1873,8 +1886,11 @@ void handlePut(const crow::Request &req, crow::Response &res,
boost::beast::http::
status::
forbidden,
- e->name,
- e->message);
+ (e) ? e->name
+ : ec.category()
+ .name(),
+ (e) ? e->message
+ : ec.message());
}
else
{