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>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 7da7d0a..c44c63f 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -480,9 +480,7 @@
                         const boost::system::error_code ec) {
         if (ec)
         {
-            messages::internalError(asyncResp->res, "/IPv4Addresses/" +
-                                                        std::to_string(ipIdx) +
-                                                        "/" + name);
+            messages::internalError(asyncResp->res);
         }
         else
         {
@@ -522,9 +520,7 @@
                         const boost::system::error_code ec) {
         if (ec)
         {
-            messages::internalError(asyncResp->res, "/IPv4Addresses/" +
-                                                        std::to_string(ipIdx) +
-                                                        "/AddressOrigin");
+            messages::internalError(asyncResp->res);
         }
         else
         {
@@ -564,9 +560,7 @@
                         const boost::system::error_code ec) {
         if (ec)
         {
-            messages::internalError(asyncResp->res, "/IPv4Addresses/" +
-                                                        std::to_string(ipIdx) +
-                                                        "/SubnetMask");
+            messages::internalError(asyncResp->res);
         }
         else
         {
@@ -620,9 +614,7 @@
         [ipIdx, asyncResp](const boost::system::error_code ec) {
             if (ec)
             {
-                messages::internalError(asyncResp->res,
-                                        "/IPv4Addresses/" +
-                                            std::to_string(ipIdx) + "/");
+                messages::internalError(asyncResp->res);
             }
             else
             {
@@ -653,9 +645,7 @@
                             asyncResp](const boost::system::error_code ec) {
         if (ec)
         {
-            messages::internalError(asyncResp->res, "/IPv4Addresses/" +
-                                                        std::to_string(ipIdx) +
-                                                        "/");
+            messages::internalError(asyncResp->res);
         }
     };
 
@@ -872,36 +862,35 @@
         if (!input.is_object())
         {
             messages::propertyValueTypeError(asyncResp->res, input.dump(),
-                                             "VLAN", "/");
+                                             "VLAN");
             return;
         }
 
         nlohmann::json::const_iterator vlanEnable = input.find("VLANEnable");
         if (vlanEnable == input.end())
         {
-            messages::propertyMissing(asyncResp->res, "VLANEnable",
-                                      "/VLANEnable");
+            messages::propertyMissing(asyncResp->res, "VLANEnable");
             return;
         }
         const bool *vlanEnableBool = vlanEnable->get_ptr<const bool *>();
         if (vlanEnableBool == nullptr)
         {
             messages::propertyValueTypeError(asyncResp->res, vlanEnable->dump(),
-                                             "VLANEnable", "/VLANEnable");
+                                             "VLANEnable");
             return;
         }
 
         nlohmann::json::const_iterator vlanId = input.find("VLANId");
         if (vlanId == input.end())
         {
-            messages::propertyMissing(asyncResp->res, "VLANId", "/VLANId");
+            messages::propertyMissing(asyncResp->res, "VLANId");
             return;
         }
         const uint64_t *vlanIdUint = vlanId->get_ptr<const uint64_t *>();
         if (vlanIdUint == nullptr)
         {
             messages::propertyValueTypeError(asyncResp->res, vlanId->dump(),
-                                             "VLANId", "/VLANId");
+                                             "VLANId");
             return;
         }
 
@@ -909,8 +898,7 @@
         {
             // This interface is not a VLAN. Cannot do anything with it
             // TODO(kkowalsk) Change this message
-            messages::propertyNotWritable(asyncResp->res, "VLANEnable",
-                                          "/VLANEnable");
+            messages::propertyNotWritable(asyncResp->res, "VLANEnable");
 
             return;
         }
@@ -963,23 +951,23 @@
         if (newHostname == nullptr)
         {
             messages::propertyValueTypeError(asyncResp->res, input.dump(),
-                                             "HostName", "/HostName");
+                                             "HostName");
             return;
         }
 
         // Change hostname
-        setHostName(
-            *newHostname, [asyncResp, newHostname{std::string(*newHostname)}](
-                              const boost::system::error_code ec) {
-                if (ec)
-                {
-                    messages::internalError(asyncResp->res, "/HostName");
-                }
-                else
-                {
-                    asyncResp->res.jsonValue["HostName"] = newHostname;
-                }
-            });
+        setHostName(*newHostname,
+                    [asyncResp, newHostname{std::string(*newHostname)}](
+                        const boost::system::error_code ec) {
+                        if (ec)
+                        {
+                            messages::internalError(asyncResp->res);
+                        }
+                        else
+                        {
+                            asyncResp->res.jsonValue["HostName"] = newHostname;
+                        }
+                    });
     }
 
     void handleIPv4Patch(
@@ -990,16 +978,15 @@
         if (!input.is_array())
         {
             messages::propertyValueTypeError(asyncResp->res, input.dump(),
-                                             "IPv4Addresses", "/IPv4Addresses");
+                                             "IPv4Addresses");
             return;
         }
 
         // According to Redfish PATCH definition, size must be at least equal
         if (input.size() < ipv4Data.size())
         {
-            // TODO(kkowalsk) This should be a message indicating that not
-            // enough data has been provided
-            messages::internalError(asyncResp->res, "/IPv4Addresses");
+            messages::propertyValueFormatError(asyncResp->res, input.dump(),
+                                               "IPv4Addresses");
             return;
         }
 
@@ -1009,12 +996,13 @@
         for (const nlohmann::json &thisJson : input)
         {
             std::string pathString =
-                "/IPv4Addresses/" + std::to_string(entryIdx);
+                "IPv4Addresses/" + std::to_string(entryIdx);
             // Check that entry is not of some unexpected type
             if (!thisJson.is_object() && !thisJson.is_null())
             {
-                messages::propertyValueTypeError(
-                    asyncResp->res, thisJson.dump(), "IPv4Address", pathString);
+                messages::propertyValueTypeError(asyncResp->res,
+                                                 thisJson.dump(),
+                                                 pathString + "/IPv4Address");
 
                 continue;
             }
@@ -1027,9 +1015,9 @@
                 addressField = addressFieldIt->get_ptr<const std::string *>();
                 if (addressField == nullptr)
                 {
-                    messages::propertyValueFormatError(
-                        asyncResp->res, addressFieldIt->dump(), "Address",
-                        pathString + "/Address");
+                    messages::propertyValueFormatError(asyncResp->res,
+                                                       addressFieldIt->dump(),
+                                                       pathString + "/Address");
                     continue;
                 }
                 else
@@ -1037,7 +1025,7 @@
                     if (!ipv4VerifyIpAndGetBitcount(*addressField))
                     {
                         messages::propertyValueFormatError(
-                            asyncResp->res, *addressField, "Address",
+                            asyncResp->res, *addressField,
                             pathString + "/Address");
                         continue;
                     }
@@ -1054,7 +1042,7 @@
                 if (subnetField == nullptr)
                 {
                     messages::propertyValueFormatError(
-                        asyncResp->res, *subnetField, "SubnetMask",
+                        asyncResp->res, *subnetField,
                         pathString + "/SubnetMask");
                     continue;
                 }
@@ -1065,7 +1053,7 @@
                                                     &*prefixLength))
                     {
                         messages::propertyValueFormatError(
-                            asyncResp->res, *subnetField, "SubnetMask",
+                            asyncResp->res, *subnetField,
                             pathString + "/SubnetMask");
                         continue;
                     }
@@ -1083,7 +1071,7 @@
                 if (addressOriginField == nullptr)
                 {
                     messages::propertyValueFormatError(
-                        asyncResp->res, *addressOriginField, "AddressOrigin",
+                        asyncResp->res, *addressOriginField,
                         pathString + "/AddressOrigin");
                     continue;
                 }
@@ -1097,7 +1085,7 @@
                     {
                         messages::propertyValueNotInList(
                             asyncResp->res, *addressOriginField,
-                            "AddressOrigin", pathString + "/AddressOrigin");
+                            pathString + "/AddressOrigin");
                         continue;
                     }
                 }
@@ -1113,9 +1101,8 @@
                 if (gatewayField == nullptr ||
                     !ipv4VerifyIpAndGetBitcount(*gatewayField))
                 {
-                    messages::propertyValueFormatError(asyncResp->res,
-                                                       *gatewayField, "Gateway",
-                                                       pathString + "/Gateway");
+                    messages::propertyValueFormatError(
+                        asyncResp->res, *gatewayField, pathString + "/Gateway");
                     continue;
                 }
             }
@@ -1132,9 +1119,7 @@
                                         const boost::system::error_code ec) {
                         if (ec)
                         {
-                            messages::internalError(asyncResp->res,
-                                                    "/IPv4Addresses/" +
-                                                        entryIdx + "/");
+                            messages::internalError(asyncResp->res);
                             return;
                         }
                         asyncResp->res.jsonValue["IPv4Addresses"][entryIdx] =
@@ -1157,11 +1142,7 @@
                                 const boost::system::error_code ec) {
                                 if (ec)
                                 {
-                                    messages::internalError(
-                                        asyncResp->res,
-                                        "/IPv4Addresses/" +
-                                            std::to_string(entryIdx) +
-                                            "/Address");
+                                    messages::internalError(asyncResp->res);
                                     return;
                                 }
                                 asyncResp->res
@@ -1202,11 +1183,7 @@
                                 const boost::system::error_code ec) {
                                 if (ec)
                                 {
-                                    messages::internalError(
-                                        asyncResp->res,
-                                        "/IPv4Addresses/" +
-                                            std::to_string(entryIdx) +
-                                            "/Gateway");
+                                    messages::internalError(asyncResp->res);
                                     return;
                                 }
                                 asyncResp->res
@@ -1232,21 +1209,21 @@
                 // Create IPv4 with provided data
                 if (gatewayField == nullptr)
                 {
-                    messages::propertyMissing(asyncResp->res, "Gateway",
+                    messages::propertyMissing(asyncResp->res,
                                               pathString + "/Gateway");
                     continue;
                 }
 
                 if (addressField == nullptr)
                 {
-                    messages::propertyMissing(asyncResp->res, "Address",
+                    messages::propertyMissing(asyncResp->res,
                                               pathString + "/Address");
                     continue;
                 }
 
                 if (!prefixLength)
                 {
-                    messages::propertyMissing(asyncResp->res, "SubnetMask",
+                    messages::propertyMissing(asyncResp->res,
                                               pathString + "/SubnetMask");
                     continue;
                 }
@@ -1400,8 +1377,8 @@
                     else if (propertyIt.key() == "IPv6Addresses")
                     {
                         // TODO(kkowalsk) IPv6 Not supported on D-Bus yet
-                        messages::propertyNotWritable(
-                            asyncResp->res, propertyIt.key(), propertyIt.key());
+                        messages::propertyNotWritable(asyncResp->res,
+                                                      propertyIt.key());
                     }
                     else
                     {
@@ -1412,14 +1389,12 @@
                         {
                             // Field not in scope of defined fields
                             messages::propertyUnknown(asyncResp->res,
-                                                      propertyIt.key(),
                                                       propertyIt.key());
                         }
                         else
                         {
                             // User attempted to modify non-writable field
                             messages::propertyNotWritable(asyncResp->res,
-                                                          propertyIt.key(),
                                                           propertyIt.key());
                         }
                     }
@@ -1607,14 +1582,12 @@
                         {
                             // Field not in scope of defined fields
                             messages::propertyUnknown(asyncResp->res,
-                                                      propertyIt.key(),
                                                       propertyIt.key());
                         }
                         else
                         {
                             // User attempted to modify non-writable field
                             messages::propertyNotWritable(asyncResp->res,
-                                                          propertyIt.key(),
                                                           propertyIt.key());
                         }
                     }
@@ -1789,7 +1762,7 @@
         auto vlanIdJson = json.find("VLANId");
         if (vlanIdJson == json.end())
         {
-            messages::propertyMissing(asyncResp->res, "VLANId", "/VLANId");
+            messages::propertyMissing(asyncResp->res, "VLANId");
             return;
         }
 
@@ -1797,7 +1770,7 @@
         if (vlanId == nullptr)
         {
             messages::propertyValueTypeError(asyncResp->res, vlanIdJson->dump(),
-                                             "VLANId", "/VLANId");
+                                             "VLANId");
             return;
         }
         const std::string &rootInterfaceName = params[0];
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index c9555a1..20825d9 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -851,15 +851,14 @@
         nlohmann::json::const_iterator caIt = rawPECICmd.find("ClientAddress");
         if (caIt == rawPECICmd.end())
         {
-            messages::propertyMissing(asyncResp->res, "ClientAddress",
-                                      "/ClientAddress");
+            messages::propertyMissing(asyncResp->res, "ClientAddress");
             return;
         }
         const uint64_t *ca = caIt->get_ptr<const uint64_t *>();
         if (ca == nullptr)
         {
             messages::propertyValueTypeError(asyncResp->res, caIt->dump(),
-                                             "ClientAddress", "/ClientAddress");
+                                             "ClientAddress");
             return;
         }
         // Get the Read Length from the request
@@ -867,15 +866,14 @@
         nlohmann::json::const_iterator rlIt = rawPECICmd.find("ReadLength");
         if (rlIt == rawPECICmd.end())
         {
-            messages::propertyMissing(asyncResp->res, "ReadLength",
-                                      "/ReadLength");
+            messages::propertyMissing(asyncResp->res, "ReadLength");
             return;
         }
         const uint64_t *rl = rlIt->get_ptr<const uint64_t *>();
         if (rl == nullptr)
         {
             messages::propertyValueTypeError(asyncResp->res, rlIt->dump(),
-                                             "ReadLength", "/ReadLength");
+                                             "ReadLength");
             return;
         }
         // Get the PECI Command from the request
@@ -883,8 +881,7 @@
         nlohmann::json::const_iterator pcIt = rawPECICmd.find("PECICommand");
         if (pcIt == rawPECICmd.end())
         {
-            messages::propertyMissing(asyncResp->res, "PECICommand",
-                                      "/PECICommand");
+            messages::propertyMissing(asyncResp->res, "PECICommand");
             return;
         }
         std::vector<uint8_t> peciCommand;
@@ -895,8 +892,7 @@
             {
                 messages::propertyValueTypeError(
                     asyncResp->res, pc.dump(),
-                    "PECICommand/" + std::to_string(peciCommand.size()),
-                    "/PECICommand");
+                    "PECICommand/" + std::to_string(peciCommand.size()));
                 return;
             }
             peciCommand.push_back(static_cast<uint8_t>(*val));
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 4c56cdf..d4e7344 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -182,7 +182,7 @@
                     if (findName == intfPair.second.end())
                     {
                         BMCWEB_LOG_ERROR << "Pid Field missing Name";
-                        messages::internalError(asyncResp->res, "Name");
+                        messages::internalError(asyncResp->res);
                         return;
                     }
                     const std::string* namePtr =
@@ -251,8 +251,7 @@
                             if (classPtr == nullptr)
                             {
                                 BMCWEB_LOG_ERROR << "Pid Class Field illegal";
-                                messages::internalError(asyncResp->res,
-                                                        "Class");
+                                messages::internalError(asyncResp->res);
                                 return;
                             }
                             bool isFan = *classPtr == "fan";
@@ -295,8 +294,7 @@
                                 {
                                     BMCWEB_LOG_ERROR
                                         << "Zones Pid Field Illegal";
-                                    messages::internalError(asyncResp->res,
-                                                            "Zones");
+                                    messages::internalError(asyncResp->res);
                                     return;
                                 }
                                 auto& data = element[propertyPair.first];
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index f096630..a46cb47 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -161,8 +161,7 @@
                                     resp) {
                                 if (ec)
                                 {
-                                    messages::internalError(asyncResp->res,
-                                                            "/" + service);
+                                    messages::internalError(asyncResp->res);
                                     return;
                                 }
                                 const std::vector<std::tuple<
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index b0a2948..68449c0 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -171,12 +171,12 @@
         {
             if (username.empty())
             {
-                messages::propertyMissing(res, "UserName", "UserName");
+                messages::propertyMissing(res, "UserName");
             }
 
             if (password.empty())
             {
-                messages::propertyMissing(res, "Password", "Password");
+                messages::propertyMissing(res, "Password");
             }
             res.end();
 
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 4ab4eb9..a1fbd0a 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -782,8 +782,8 @@
             }
             else
             {
-                messages::propertyValueNotInList(
-                    res, *indicatorLed, "IndicatorLED", "IndicatorLED");
+                messages::propertyValueNotInList(res, *indicatorLed,
+                                                 "IndicatorLED");
                 return;
             }