Add line information to JsonSerializationException (#1829)

This commit is contained in:
James Newton-King
2018-09-16 14:10:33 -07:00
committed by GitHub
parent c7d1615191
commit d7150871cb
3 changed files with 59 additions and 3 deletions
+5 -1
View File
@@ -121,13 +121,17 @@ namespace Newtonsoft.Json.Tests
[Test]
public void PopulateObjectWithOnlyComment()
{
ExceptionAssert.Throws<JsonSerializationException>(() =>
var ex = ExceptionAssert.Throws<JsonSerializationException>(() =>
{
string json = @"// file header";
PopulateTestObject o = new PopulateTestObject();
JsonConvert.PopulateObject(json, o);
}, "No JSON content found. Path '', line 1, position 14.");
Assert.AreEqual(1, ex.LineNumber);
Assert.AreEqual(14, ex.LinePosition);
Assert.AreEqual(string.Empty, ex.Path);
}
[Test]