Handle JsonException thrown from JSON parser. (#286)
We were allowing some exceptions to escape, which would cause a crash of the reader.
This commit is contained in:
Родитель
029aeb1aea
Коммит
29682524ff
|
@ -123,6 +123,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
var markers = Array.Empty<Marker>();
|
||||
Dictionary<string, GenericDataObject> extraData = null;
|
||||
|
||||
try
|
||||
{
|
||||
reader.ConsumeToken();
|
||||
|
||||
while (reader.Read())
|
||||
|
@ -272,6 +274,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
throw reader.ThrowUnexpectedToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
// Re-throw errors from the JSON parser using our own exception.
|
||||
throw Exception(e.Message);
|
||||
}
|
||||
|
||||
throw EofException;
|
||||
}
|
||||
|
|
|
@ -48,19 +48,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization
|
|||
|
||||
// Consumes a token from the stream.
|
||||
internal void ConsumeToken()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_jsonReader.Read())
|
||||
{
|
||||
throw EofException;
|
||||
}
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
throw Exception(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Skip() => _jsonReader.Skip();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче