diff options
| author | Jason M. Bills <jason.m.bills@linux.intel.com> | 2018-11-06 15:01:08 -0800 |
|---|---|---|
| committer | Jason M. Bills <jason.m.bills@linux.intel.com> | 2018-11-15 11:47:50 -0800 |
| commit | a08b46ccf0fc0081cecc4843484c4f0eb13f5a9a (patch) | |
| tree | d5ff3c2f9680cbdb2df2b4e45557d7ebf2d8b324 /redfish-core/include | |
| parent | 162be7b8b816ff34d08b8d5db461de067356b4d9 (diff) | |
| download | bmcweb-a08b46ccf0fc0081cecc4843484c4f0eb13f5a9a.tar.gz bmcweb-a08b46ccf0fc0081cecc4843484c4f0eb13f5a9a.zip | |
Simplify Redfish error message property interface
The error message code used a json_pointer object which must
begin with a '/' character and had to be sent as an extra
parameter. This change simplifies the interface by using a
string so there doesn't have to be a '/'. This allowed the
same property argument passed for the message to be used
for the property field path.
Tested: Sent an error with a property and verified that it is
correctly displayed.
Change-Id: I0571e2eee627cedf29d751588a4f1bceee66f084
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Diffstat (limited to 'redfish-core/include')
| -rw-r--r-- | redfish-core/include/error_messages.hpp | 95 | ||||
| -rw-r--r-- | redfish-core/include/utils/json_utils.hpp | 6 |
2 files changed, 4 insertions, 97 deletions
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp index f404de3..d92a2b4 100644 --- a/redfish-core/include/error_messages.hpp +++ b/redfish-core/include/error_messages.hpp @@ -87,15 +87,6 @@ void actionParameterValueFormatError(crow::Response& res, void internalError(crow::Response& res); /** - * @brief Formats InternalError message into JSON for the specified field - * Message body: "The request failed due to an internal service error. The - * service is still operational." - * - * - * @returns Message InternalError formatted to JSON */ -void internalError(crow::Response& res, const std::string& fieldPath); - -/** * @brief Formats UnrecognizedRequestBody message into JSON * Message body: "The service detected a malformed request body that it was * unable to interpret." @@ -203,20 +194,6 @@ void propertyValueFormatError(crow::Response& res, const std::string& arg1, const std::string& arg2); /** - * @brief Formats PropertyValueFormatError message into JSON for the specified - * property - * Message body: "The value <arg1> for the property <arg2> is of a different - * format than the property can accept." - * - * @param[in] arg1 Parameter of message that will replace %1 in its body. - * @param[in] arg2 Parameter of message that will replace %2 in its body. - * - * @returns Message PropertyValueFormatError formatted to JSON */ -void propertyValueFormatError(crow::Response& res, const std::string& arg1, - const std::string& arg2, - const std::string property); - -/** * @brief Formats PropertyValueNotInList message into JSON * Message body: "The value <arg1> for the property <arg2> is not in the list of * acceptable values." @@ -229,20 +206,6 @@ void propertyValueNotInList(crow::Response& res, const std::string& arg1, const std::string& arg2); /** - * @brief Formats PropertyValueNotInList message into JSON for the specified - * property - * Message body: "The value <arg1> for the property <arg2> is not in - * the list of acceptable values." - * - * @param[in] arg1 Parameter of message that will replace %1 in its body. - * @param[in] arg2 Parameter of message that will replace %2 in its body. - * - * @returns Message PropertyValueNotInList formatted to JSON */ -void propertyValueNotInList(crow::Response& res, const std::string& arg1, - const std::string& arg2, - const std::string property); - -/** * @brief Formats ResourceAtUriInUnknownFormat message into JSON * Message body: "The resource at <arg1> is in a format not recognized by the * service." @@ -326,20 +289,6 @@ void propertyValueTypeError(crow::Response& res, const std::string& arg1, const std::string& arg2); /** - * @brief Formats PropertyValueTypeError message into JSON for the specified - * property - * Message body: "The value <arg1> for the property <arg2> is of a - * different type than the property can accept." - * - * @param[in] arg1 Parameter of message that will replace %1 in its body. - * @param[in] arg2 Parameter of message that will replace %2 in its body. - * - * @returns Message PropertyValueTypeError formatted to JSON */ -void propertyValueTypeError(crow::Response& res, const std::string& arg1, - const std::string& arg2, - const std::string& property); - -/** * @brief Formats ResourceNotFound message into JSON * Message body: "The requested resource of type <arg1> named <arg2> was not * found." @@ -372,18 +321,6 @@ void couldNotEstablishConnection(crow::Response& res, const std::string& arg1); void propertyNotWritable(crow::Response& res, const std::string& arg1); /** - * @brief Formats PropertyNotWritable message into JSON for the specified - * property - * Message body: "The property <arg1> is a read only property and - * cannot be assigned a value." - * - * @param[in] arg1 Parameter of message that will replace %1 in its body. - * - * @returns Message PropertyNotWritable formatted to JSON */ -void propertyNotWritable(crow::Response& res, const std::string& arg1, - const std::string& property); - -/** * @brief Formats QueryParameterValueTypeError message into JSON * Message body: "The value <arg1> for the query parameter <arg2> is of a * different type than the parameter can accept." @@ -493,14 +430,6 @@ void generalError(crow::Response& res); void success(crow::Response& res); /** - * @brief Formats Success message into JSON for the specified field - * Message body: "Successfully Completed Request" - * - * - * @returns Message Success formatted to JSON */ -void success(crow::Response& res, const std::string& fieldPath); - -/** * @brief Formats Created message into JSON * Message body: "The resource has been created successfully" * @@ -528,17 +457,6 @@ void noOperation(crow::Response& res); void propertyUnknown(crow::Response& res, const std::string& arg1); /** - * @brief Formats PropertyUnknown message into JSON for the specified property - * Message body: "The property <arg1> is not in the list of valid properties for - * the resource." - * - * @param[in] arg1 Parameter of message that will replace %1 in its body. - * - * @returns Message PropertyUnknown formatted to JSON */ -void propertyUnknown(crow::Response& res, const std::string& arg1, - const std::string& property); - -/** * @brief Formats NoValidSession message into JSON * Message body: "There is no valid session established with the * implementation." @@ -677,17 +595,6 @@ void queryParameterValueFormatError(crow::Response& res, void propertyMissing(crow::Response& res, const std::string& arg1); /** - * @brief Formats PropertyMissing message into JSON for the specified property - * Message body: "The property <arg1> is a required property and must be - * included in the request." - * - * @param[in] arg1 Parameter of message that will replace %1 in its body. - * - * @returns Message PropertyMissing formatted to JSON */ -void propertyMissing(crow::Response& res, const std::string& arg1, - const std::string& property); - -/** * @brief Formats ResourceExhaustion message into JSON * Message body: "The resource <arg1> was unable to satisfy the request due to * unavailability of resources." @@ -703,7 +610,7 @@ void resourceExhaustion(crow::Response& res, const std::string& arg1); * * * @returns Message AccountModified formatted to JSON */ -void accountModified(crow::Response& res, const std::string& fieldPath); +void accountModified(crow::Response& res); /** * @brief Formats QueryParameterOutOfRange message into JSON diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp index f02fc67..e56a0d6 100644 --- a/redfish-core/include/utils/json_utils.hpp +++ b/redfish-core/include/utils/json_utils.hpp @@ -60,7 +60,7 @@ void readJsonValues(const std::string& key, nlohmann::json& jsonValue, crow::Response& res, std::bitset<Count>& handled) { BMCWEB_LOG_DEBUG << "Unable to find variable for key" << key; - messages::propertyUnknown(res, key, key); + messages::propertyUnknown(res, key); } template <size_t Count, size_t Index, typename ValueType, @@ -84,7 +84,7 @@ void readJsonValues(const std::string& key, nlohmann::json& jsonValue, { BMCWEB_LOG_DEBUG << "Value for key " << key << " was incorrect type: " << jsonValue.type_name(); - messages::propertyValueTypeError(res, jsonValue.dump(), key, key); + messages::propertyValueTypeError(res, jsonValue.dump(), key); return; } @@ -103,7 +103,7 @@ void handleMissing(std::bitset<Count>& handled, crow::Response& res, { if (!handled.test(Index) && unpackValue<ValueType>::isRequired::value) { - messages::propertyMissing(res, key, key); + messages::propertyMissing(res, key); } details::handleMissing<Index + 1, Count>(handled, res, in...); } |

