Make propertyValueFormatError more typesafe
Similar to other patches, make propertyValueFormatError accept a
nlohmann::json object, which removes a lot of the unsafe dump code that
we have littered about.
Tested: No easy to replicate error. Code is identical to previous
patchsets. Inspection and code compilation only.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic9d0f196b6e198073189f744b738db7ffa2f1b74
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 411659d..9aadaea 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1261,11 +1261,8 @@
address, "SubnetMask", subnetMask,
"Gateway", gateway))
{
- messages::propertyValueFormatError(
- asyncResp->res,
- thisJson.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace),
- pathString);
+ messages::propertyValueFormatError(asyncResp->res, thisJson,
+ pathString);
return;
}
@@ -1386,11 +1383,8 @@
messages::resourceCannotBeDeleted(asyncResp->res);
return;
}
- messages::propertyValueFormatError(
- asyncResp->res,
- thisJson.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace),
- pathString);
+ messages::propertyValueFormatError(asyncResp->res, thisJson,
+ pathString);
return;
}
@@ -1455,11 +1449,8 @@
if (!json_util::readJson(thisJsonCopy, asyncResp->res, "Address",
address, "PrefixLength", prefixLength))
{
- messages::propertyValueFormatError(
- asyncResp->res,
- thisJson.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace),
- pathString);
+ messages::propertyValueFormatError(asyncResp->res, thisJson,
+ pathString);
return;
}
@@ -1526,11 +1517,8 @@
messages::resourceCannotBeDeleted(asyncResp->res);
return;
}
- messages::propertyValueFormatError(
- asyncResp->res,
- thisJson.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace),
- pathString);
+ messages::propertyValueFormatError(asyncResp->res, thisJson,
+ pathString);
return;
}