summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-01-10 00:22:30 +0300
committerEd Tanous <ed.tanous@intel.com>2019-01-10 20:14:52 +0300
commitc0eb9bd95afa900dc808dce7c2c5fa521ba828f5 (patch)
tree9c7e4fd1f73240595b386b5231cb5246c7e0bc4c
parent673eda6dd745a08651764861dd2de9bd597a594c (diff)
downloadbmcweb-c0eb9bd95afa900dc808dce7c2c5fa521ba828f5.tar.xz
REST: Use status 400 for method arg problems
Use 400, which is a client error, for errors when deciphering method call arguments as opposed to a server error, 500. The robot testcases expect this and it also makes sense since the client must have passed in a bad argument. Only the error that results from a method call failing will be 500. Resolves openbmc/bmcweb#25 Change-Id: I9504905992fee3bc0119ff7cae8512eba899daa4 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r--include/openbmc_dbus_rest.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 8b9bd05e94..da59d2597b 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -39,6 +39,7 @@ const std::string notFoundMsg = "404 Not Found";
const std::string badReqMsg = "400 Bad Request";
const std::string methodNotAllowedMsg = "405 Method Not Allowed";
const std::string forbiddenMsg = "403 Forbidden";
+const std::string methodFailedMsg = "500 Method Call Failed";
const std::string notFoundDesc =
"org.freedesktop.DBus.Error.FileNotFound: path or object not found";
@@ -412,8 +413,8 @@ struct InProgressActionData
void setErrorStatus(const std::string &desc)
{
- setErrorResponse(res, boost::beast::http::status::internal_server_error,
- desc, badReqMsg);
+ setErrorResponse(res, boost::beast::http::status::bad_request, desc,
+ badReqMsg);
}
crow::Response &res;
std::string path;
@@ -857,8 +858,12 @@ void findActionOnInterface(std::shared_ptr<InProgressActionData> transaction,
sdbusplus::message::message &m) {
if (ec)
{
- transaction->setErrorStatus(
- "Method call failed");
+ setErrorResponse(
+ transaction->res,
+ boost::beast::http::status::
+ internal_server_error,
+ "Method call failed",
+ methodFailedMsg);
return;
}
transaction->res.jsonValue = {