Add logging offset for Json parsing errors
This commit is contained in:
@@ -1016,7 +1016,7 @@ public:
|
|||||||
document.Parse(json.Get(), json.Length());
|
document.Parse(json.Get(), json.Length());
|
||||||
if (document.HasParseError())
|
if (document.HasParseError())
|
||||||
{
|
{
|
||||||
Log::JsonParseException(document.GetParseError());
|
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset());
|
||||||
DebugLog::ThrowException("Failed to parse Json.");
|
DebugLog::ThrowException("Failed to parse Json.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,16 +118,16 @@ void BinaryAsset::GetImportMetadata(String& path, String& username) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse metadata and try to get import info
|
// Parse metadata and try to get import info
|
||||||
rapidjson_flax::Document doc;
|
rapidjson_flax::Document document;
|
||||||
doc.Parse((const char*)Metadata.Get(), Metadata.Length());
|
document.Parse((const char*)Metadata.Get(), Metadata.Length());
|
||||||
if (doc.HasParseError() == false)
|
if (document.HasParseError() == false)
|
||||||
{
|
{
|
||||||
path = JsonTools::GetString(doc, "ImportPath");
|
path = JsonTools::GetString(document, "ImportPath");
|
||||||
username = JsonTools::GetString(doc, "ImportUsername");
|
username = JsonTools::GetString(document, "ImportUsername");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::JsonParseException(doc.GetParseError(), GetPath());
|
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), GetPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ Asset::LoadResult JsonAssetBase::loadAsset()
|
|||||||
Document.Parse(data.Get<char>(), data.Length());
|
Document.Parse(data.Get<char>(), data.Length());
|
||||||
if (Document.HasParseError())
|
if (Document.HasParseError())
|
||||||
{
|
{
|
||||||
Log::JsonParseException(Document.GetParseError());
|
Log::JsonParseException(Document.GetParseError(), Document.GetErrorOffset());
|
||||||
return LoadResult::CannotLoadData;
|
return LoadResult::CannotLoadData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ bool JsonStorageProxy::GetAssetInfo(const StringView& path, Guid& resultId, Stri
|
|||||||
document.Parse((const char*)fileData.Get(), fileData.Count());
|
document.Parse((const char*)fileData.Get(), fileData.Count());
|
||||||
if (document.HasParseError())
|
if (document.HasParseError())
|
||||||
{
|
{
|
||||||
Log::JsonParseException(document.GetParseError(), String(path));
|
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), String(path));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ bool JsonStorageProxy::ChangeId(const StringView& path, const Guid& newId)
|
|||||||
document.Parse((const char*)fileData.Get(), fileData.Count());
|
document.Parse((const char*)fileData.Get(), fileData.Count());
|
||||||
if (document.HasParseError())
|
if (document.HasParseError())
|
||||||
{
|
{
|
||||||
Log::JsonParseException(document.GetParseError(), String(path));
|
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), String(path));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ namespace Log
|
|||||||
/// Init
|
/// Init
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="error">Parsing error code.</param>
|
/// <param name="error">Parsing error code.</param>
|
||||||
JsonParseException(ErrorCode error)
|
/// <param name="offset">Parsing error location.</param>
|
||||||
: JsonParseException(error, String::Empty)
|
JsonParseException(ErrorCode error, size_t offset)
|
||||||
|
: JsonParseException(error, offset, String::Empty)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,9 +33,10 @@ namespace Log
|
|||||||
/// Creates default exception with additional data
|
/// Creates default exception with additional data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="error">Parsing error code.</param>
|
/// <param name="error">Parsing error code.</param>
|
||||||
|
/// <param name="offset">Parsing error location.</param>
|
||||||
/// <param name="additionalInfo">Additional information that help describe error</param>
|
/// <param name="additionalInfo">Additional information that help describe error</param>
|
||||||
JsonParseException(ErrorCode error, const String& additionalInfo)
|
JsonParseException(ErrorCode error, size_t offset, const String& additionalInfo)
|
||||||
: Exception(String::Format(TEXT("Parsing Json failed with error code {0}. {1}"), static_cast<int32>(error), GetParseError_En(error)), additionalInfo)
|
: Exception(String::Format(TEXT("Parsing Json failed with error code {0} (offset {2}). {1}"), static_cast<int32>(error), GetParseError_En(error), offset), additionalInfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1547,7 +1547,7 @@ bool Actor::FromBytes(const Span<byte>& data, Array<Actor*>& output, ISerializeM
|
|||||||
document.Parse(buffer, bufferSize);
|
document.Parse(buffer, bufferSize);
|
||||||
if (document.HasParseError())
|
if (document.HasParseError())
|
||||||
{
|
{
|
||||||
Log::JsonParseException(document.GetParseError());
|
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1587,7 +1587,7 @@ bool Actor::FromBytes(const Span<byte>& data, Array<Actor*>& output, ISerializeM
|
|||||||
document.Parse(buffer, bufferSize);
|
document.Parse(buffer, bufferSize);
|
||||||
if (document.HasParseError())
|
if (document.HasParseError())
|
||||||
{
|
{
|
||||||
Log::JsonParseException(document.GetParseError());
|
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1699,7 +1699,7 @@ void Actor::FromJson(const StringAnsiView& json)
|
|||||||
document.Parse(json.Get(), json.Length());
|
document.Parse(json.Get(), json.Length());
|
||||||
if (document.HasParseError())
|
if (document.HasParseError())
|
||||||
{
|
{
|
||||||
Log::JsonParseException(document.GetParseError());
|
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -786,7 +786,7 @@ bool Level::loadScene(const BytesContainer& sceneData, bool autoInitialize, Scen
|
|||||||
document.Parse(sceneData.Get<char>(), sceneData.Length());
|
document.Parse(sceneData.Get<char>(), sceneData.Length());
|
||||||
if (document.HasParseError())
|
if (document.HasParseError())
|
||||||
{
|
{
|
||||||
Log::JsonParseException(document.GetParseError());
|
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user