Exposing the Settings Registry parse error to a Native UI dialog (#864)

* Exposing the Settings Registry parse error to a Native UI dialog

* Fixing format specifier for the rapidjson error offset
This commit is contained in:
lumberyard-employee-dm
2021-05-21 13:18:41 -05:00
committed by GitHub
parent 7c2051ae54
commit f5bc191a55
@@ -14,6 +14,7 @@
#include <cerrno>
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/JSON/error/en.h>
#include <AzCore/NativeUI//NativeUIRequests.h>
#include <AzCore/Serialization/Json/JsonSerialization.h>
#include <AzCore/Serialization/Json/StackedString.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
@@ -1061,15 +1062,23 @@ namespace AZ
jsonPatch.ParseInsitu<flags>(scratchBuffer.data());
if (jsonPatch.HasParseError())
{
auto nativeUI = AZ::Interface<NativeUI::NativeUIRequests>::Get();
if (jsonPatch.GetParseError() == rapidjson::kParseErrorDocumentEmpty)
{
AZ_Warning("Settings Registry", false, R"(Unable to parse registry file "%s" due to json error "%s" at offset %llu.)",
AZ_Warning("Settings Registry", false, R"(Unable to parse registry file "%s" due to json error "%s" at offset %zu.)",
path, GetParseError_En(jsonPatch.GetParseError()), jsonPatch.GetErrorOffset());
}
else
{
AZ_Error("Settings Registry", false, R"(Unable to parse registry file "%s" due to json error "%s" at offset %llu.)", path,
using ErrorString = AZStd::fixed_string<4096>;
auto jsonError = ErrorString::format(R"(Unable to parse registry file "%s" due to json error "%s" at offset %zu.)", path,
GetParseError_En(jsonPatch.GetParseError()), jsonPatch.GetErrorOffset());
AZ_Error("Settings Registry", false, "%s", jsonError.c_str());
if (nativeUI)
{
nativeUI->DisplayOkDialog("Setreg(Patch) Merge Issue", AZStd::string_view(jsonError), false);
}
}
pointer.Create(m_settings, m_settings.GetAllocator()).SetObject()