1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-26 22:56:23 -04:00

Added logging of json snippets on json deserialization errors.

This commit is contained in:
Taloth Saldono
2018-07-06 21:44:15 +02:00
parent 8b8bfb9bf0
commit 0cce6b74f9
2 changed files with 87 additions and 10 deletions
@@ -1,3 +1,4 @@
using System;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Serializer;
@@ -24,5 +25,31 @@ namespace NzbDrone.Libraries.Test.JsonTests
result.ShouldBeEquivalentTo(quality, o => o.IncludingAllRuntimeProperties());
}
[Test]
public void should_log_start_snippet_on_failure()
{
try
{
Json.Deserialize<object>("asdfl kasjd fsdfs derers");
}
catch (Exception ex)
{
ex.Message.Should().Contain("snippet '<--error-->asdfl kasjd fsdfs de'");
}
}
[Test]
public void should_log_line_snippet_on_failure()
{
try
{
Json.Deserialize<object>("{ \"a\": \r\n\"b\",\r\n \"b\": \"c\", asdfl kasjd fsdfs derers vsdfsdf");
}
catch (Exception ex)
{
ex.Message.Should().Contain("snippet ' \"b\": \"c\", asdfl <--error-->kasjd fsdfs derers v'");
}
}
}
}