Handle AccountService D-bus errors

Currently LDAP configuration D-bus errors are not mapped to Redfish
Errors, so returing internalError irrespective of D-bus error.

This commit handles InvalidArgument D-bus error for LDAP config

Tested By:
Configure LDAP with various invalid arguments.

Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
Change-Id: I6adaedd936fb3d9d906750649792a4d414b54b73
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index c8fd196..c61fa46 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -317,10 +317,23 @@
                 {
                     crow::connections::systemBus->async_method_call(
                         [asyncResp, roleMapObjData, serverType, index,
-                         remoteGroup](const boost::system::error_code& ec) {
+                         remoteGroup](const boost::system::error_code& ec,
+                                      const sdbusplus::message::message& msg) {
                         if (ec)
                         {
-                            BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
+                            const sd_bus_error* dbusError = msg.get_error();
+                            if ((dbusError != nullptr) &&
+                                (dbusError->name ==
+                                 std::string_view(
+                                     "xyz.openbmc_project.Common.Error.InvalidArgument")))
+                            {
+                                BMCWEB_LOG_WARNING << "DBUS response error: "
+                                                   << ec;
+                                messages::propertyValueIncorrect(asyncResp->res,
+                                                                 "RemoteGroup",
+                                                                 *remoteGroup);
+                                return;
+                            }
                             messages::internalError(asyncResp->res);
                             return;
                         }
@@ -341,10 +354,22 @@
                 {
                     crow::connections::systemBus->async_method_call(
                         [asyncResp, roleMapObjData, serverType, index,
-                         localRole](const boost::system::error_code& ec) {
+                         localRole](const boost::system::error_code& ec,
+                                    const sdbusplus::message::message& msg) {
                         if (ec)
                         {
-                            BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
+                            const sd_bus_error* dbusError = msg.get_error();
+                            if ((dbusError != nullptr) &&
+                                (dbusError->name ==
+                                 std::string_view(
+                                     "xyz.openbmc_project.Common.Error.InvalidArgument")))
+                            {
+                                BMCWEB_LOG_WARNING << "DBUS response error: "
+                                                   << ec;
+                                messages::propertyValueIncorrect(
+                                    asyncResp->res, "LocalRole", *localRole);
+                                return;
+                            }
                             messages::internalError(asyncResp->res);
                             return;
                         }
@@ -667,11 +692,23 @@
 {
     crow::connections::systemBus->async_method_call(
         [asyncResp, ldapServerElementName,
-         serviceAddressList](const boost::system::error_code& ec) {
+         serviceAddressList](const boost::system::error_code& ec,
+                             sdbusplus::message::message& msg) {
         if (ec)
         {
-            BMCWEB_LOG_DEBUG
-                << "Error Occurred in updating the service address";
+            const sd_bus_error* dbusError = msg.get_error();
+            if ((dbusError != nullptr) &&
+                (dbusError->name ==
+                 std::string_view(
+                     "xyz.openbmc_project.Common.Error.InvalidArgument")))
+            {
+                BMCWEB_LOG_WARNING
+                    << "Error Occurred in updating the service address";
+                messages::propertyValueIncorrect(asyncResp->res,
+                                                 "ServiceAddresses",
+                                                 serviceAddressList.front());
+                return;
+            }
             messages::internalError(asyncResp->res);
             return;
         }
@@ -772,10 +809,22 @@
 {
     crow::connections::systemBus->async_method_call(
         [asyncResp, baseDNList,
-         ldapServerElementName](const boost::system::error_code& ec) {
+         ldapServerElementName](const boost::system::error_code& ec,
+                                const sdbusplus::message::message& msg) {
         if (ec)
         {
             BMCWEB_LOG_DEBUG << "Error Occurred in Updating the base DN";
+            const sd_bus_error* dbusError = msg.get_error();
+            if ((dbusError != nullptr) &&
+                (dbusError->name ==
+                 std::string_view(
+                     "xyz.openbmc_project.Common.Error.InvalidArgument")))
+            {
+                messages::propertyValueIncorrect(asyncResp->res,
+                                                 "BaseDistinguishedNames",
+                                                 baseDNList.front());
+                return;
+            }
             messages::internalError(asyncResp->res);
             return;
         }