summaryrefslogtreecommitdiff
path: root/redfish-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'redfish-core/src')
-rw-r--r--redfish-core/src/error_messages.cpp23
-rw-r--r--redfish-core/src/utils/dbus_utils.cpp49
2 files changed, 71 insertions, 1 deletions
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index 6c4282cc67..7b0251562d 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -1453,6 +1453,29 @@ void actionParameterValueTypeError(crow::Response& res,
/**
* @internal
+ * @brief Formats actionParameterValueError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json actionParameterValueError(const nlohmann::json& arg1,
+ std::string_view arg2)
+{
+ std::string arg1Str = arg1.dump(2, ' ', true,
+ nlohmann::json::error_handler_t::replace);
+ return getLog(redfish::registries::base::Index::actionParameterValueError,
+ std::to_array<std::string_view>({arg1Str, arg2}));
+}
+
+void actionParameterValueError(crow::Response& res, const nlohmann::json& arg1,
+ std::string_view arg2)
+{
+ res.result(boost::beast::http::status::bad_request);
+ addMessageToErrorJson(res.jsonValue, actionParameterValueError(arg1, arg2));
+}
+
+/**
+ * @internal
* @brief Formats SessionLimitExceeded message into JSON
*
* See header file for more information
diff --git a/redfish-core/src/utils/dbus_utils.cpp b/redfish-core/src/utils/dbus_utils.cpp
index 59ddb9d6ba..bffe7a867b 100644
--- a/redfish-core/src/utils/dbus_utils.cpp
+++ b/redfish-core/src/utils/dbus_utils.cpp
@@ -66,7 +66,54 @@ void afterSetProperty(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
messages::internalError(asyncResp->res);
return;
}
- // Only set 204 if another erro hasn't already happened.
+ // Only set 204 if another error hasn't already happened.
+ if (asyncResp->res.result() == boost::beast::http::status::ok)
+ {
+ asyncResp->res.result(boost::beast::http::status::no_content);
+ }
+};
+
+void afterSetPropertyAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& redfishActionName,
+ const std::string& redfishActionParameterName,
+ const boost::system::error_code& ec,
+ const sdbusplus::message_t& /*msg*/)
+{
+ if (ec)
+ {
+ if (ec.value() == boost::asio::error::invalid_argument)
+ {
+ BMCWEB_LOG_WARNING(
+ "Resource {} is patched with invalid argument during action {}",
+ redfishActionParameterName, redfishActionName);
+ if (redfishActionParameterName.empty())
+ {
+ messages::operationFailed(asyncResp->res);
+ }
+ else
+ {
+ messages::actionParameterValueError(asyncResp->res,
+ redfishActionParameterName,
+ redfishActionName);
+ }
+ return;
+ }
+ if (ec.value() == boost::asio::error::host_unreachable)
+ {
+ BMCWEB_LOG_WARNING(
+ "Resource {} is not found while performing action {}",
+ redfishActionParameterName, redfishActionName);
+ messages::resourceNotFound(asyncResp->res, "Actions",
+ redfishActionName);
+ return;
+ }
+
+ BMCWEB_LOG_ERROR("D-Bus error setting Redfish Property {} ec={}",
+ redfishActionParameterName, ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ // Only set 204 if another error hasn't already happened.
if (asyncResp->res.result() == boost::beast::http::status::ok)
{
asyncResp->res.result(boost::beast::http::status::no_content);