summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNan Zhou <nanzhoumails@gmail.com>2022-08-16 04:07:28 +0300
committerNan Zhou <nanzhoumails@gmail.com>2022-08-17 23:37:57 +0300
commitae6883136bfb536788ac88cfa71e3d83865a362b (patch)
tree948b537f793ee6be4dfd83ae2ce43e677f7a8d9b
parentb0d3a8562bb11ac9279aa234ce60cf619b64ca6a (diff)
downloadbmcweb-ae6883136bfb536788ac88cfa71e3d83865a362b.tar.xz
error message: add insufficientStorage
In the spec, when a response is too large, we need a error messsage to represent such error. The corresponding error is 507 Insufficient Storage, which is already in the base registry. This commit adds that utility to error messages library. Reference: redfish spec Section 7.3.2 ``` If a service cannot return the payload due to its size, it shall return the HTTP 507 Insufficient Storage status code. ``` Tested: code compies. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I1fe840f015b3d67fa2092d1d3a1f8c3fcbc2c438
-rw-r--r--redfish-core/include/error_messages.hpp9
-rw-r--r--redfish-core/src/error_messages.cpp19
2 files changed, 28 insertions, 0 deletions
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index d9f571c76b..1a5b94132d 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -1018,6 +1018,15 @@ nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2);
void invalidUpload(crow::Response& res, std::string_view arg1,
std::string_view arg2);
+/**
+ * @brief Formats InsufficientStorage message into JSON
+ * Message body: "Insufficent storage or memory available to complete the
+ * request."
+ * @returns Message InsufficientStorage formatted to JSON */
+nlohmann::json insufficientStorage();
+
+void insufficientStorage(crow::Response& res);
+
} // namespace messages
} // namespace redfish
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index cdaced6246..654353d783 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -1673,6 +1673,24 @@ void invalidUpload(crow::Response& res, std::string_view arg1,
/**
* @internal
+ * @brief Formats InsufficientStorage message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json insufficientStorage()
+{
+ return getLog(redfish::registries::base::Index::insufficientStorage, {});
+}
+
+void insufficientStorage(crow::Response& res)
+{
+ res.result(boost::beast::http::status::insufficient_storage);
+ addMessageToErrorJson(res.jsonValue, insufficientStorage());
+}
+
+/**
+ * @internal
* @brief Formats Invalid File message into JSON
*
* See header file for more information
@@ -1693,6 +1711,7 @@ nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
{"MessageSeverity", "Warning"},
{"Resolution", "None."}};
}
+
} // namespace messages
} // namespace redfish