summaryrefslogtreecommitdiff
path: root/redfish-core/lib/chassis.hpp
diff options
context:
space:
mode:
authorJason M. Bills <jason.m.bills@linux.intel.com>2018-10-09 22:45:45 +0300
committerJason M. Bills <jason.m.bills@linux.intel.com>2018-10-23 03:00:16 +0300
commitf12894f8bd7fc26ffa16e5a89072e6c19095f866 (patch)
treee2e2e1629f80a29efca04bd9714525465575549e /redfish-core/lib/chassis.hpp
parent9712f8ac42746e65f32c2bc3de0835846652568e (diff)
downloadbmcweb-f12894f8bd7fc26ffa16e5a89072e6c19095f866.tar.xz
Improve the Redfish error reporting interface
Makes the Redfish error reporting interface automatically handle setting the http status and JSON content in the response object. When using an AsyncResp object, this allows for simply calling the Redfish error and returning. Change-Id: Icfdce2de763225f070e8dd61e591f296703f46bb Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Diffstat (limited to 'redfish-core/lib/chassis.hpp')
-rw-r--r--redfish-core/lib/chassis.hpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index fa10d5c6ec..6615760834 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -80,10 +80,7 @@ class ChassisCollection : public Node
const std::vector<std::string> &chassisList) {
if (ec)
{
- messages::addMessageToErrorJson(asyncResp->res.jsonValue,
- messages::internalError());
- asyncResp->res.result(
- boost::beast::http::status::internal_server_error);
+ messages::internalError(asyncResp->res);
return;
}
nlohmann::json &chassisArray =
@@ -148,7 +145,7 @@ class Chassis : public Node
// impossible.
if (params.size() != 1)
{
- res.result(boost::beast::http::status::internal_server_error);
+ messages::internalError(res);
res.end();
return;
}
@@ -165,10 +162,7 @@ class Chassis : public Node
&subtree) {
if (ec)
{
- messages::addMessageToErrorJson(asyncResp->res.jsonValue,
- messages::internalError());
- asyncResp->res.result(
- boost::beast::http::status::internal_server_error);
+ messages::internalError(asyncResp->res);
return;
}
// Iterate over all retrieved ObjectPaths.
@@ -226,9 +220,8 @@ class Chassis : public Node
}
// Couldn't find an object with that name. return an error
- asyncResp->res.jsonValue = redfish::messages::resourceNotFound(
- "#Chassis.v1_4_0.Chassis", chassisId);
- asyncResp->res.result(boost::beast::http::status::not_found);
+ messages::resourceNotFound(
+ asyncResp->res, "#Chassis.v1_4_0.Chassis", chassisId);
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",