account_service:redfish user creation err handling

Modified POST method to handle redfish user creation
error codes.

Tested:
Tested user creation with below test cases
1)Already user exists
2)Max users reached
3)Username is NULL
4)Username is not starting with alphabet
5)Username exceed more than 16 characters
6)Invalid Password

Redfish validator test results: Passed

Signed-off-by: anil kumar appana <anil.kumarx.appana@intel.com>
Change-Id: I58361ddd4dfd067802f805f9d870b2bc1692ea1d
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index bc8ce77..0658f3f 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -1429,13 +1429,12 @@
 
                 crow::connections::systemBus->async_method_call(
                     [asyncResp, username, password{std::move(password)}](
-                        const boost::system::error_code ec) {
+                        const boost::system::error_code ec,
+                        sdbusplus::message::message& m) {
                         if (ec)
                         {
-                            messages::resourceAlreadyExists(
-                                asyncResp->res,
-                                "#ManagerAccount.v1_0_3.ManagerAccount",
-                                "UserName", username);
+                            userErrorMessageHandler(m.get_error(), asyncResp,
+                                                    username, "");
                             return;
                         }
 
@@ -1446,16 +1445,17 @@
                             // but the password set failed.Something is wrong,
                             // so delete the user that we've already created
                             crow::connections::systemBus->async_method_call(
-                                [asyncResp](
-                                    const boost::system::error_code ec) {
+                                [asyncResp,
+                                 password](const boost::system::error_code ec) {
                                     if (ec)
                                     {
                                         messages::internalError(asyncResp->res);
                                         return;
                                     }
 
-                                    messages::invalidObject(asyncResp->res,
-                                                            "Password");
+                                    // If password is invalid
+                                    messages::propertyValueFormatError(
+                                        asyncResp->res, password, "Password");
                                 },
                                 "xyz.openbmc_project.User.Manager",
                                 "/xyz/openbmc_project/user/" + username,