Skip to content

v3.1.0 - Error recording in tokens

Choose a tag to compare

@github-actions github-actions released this 21 Sep 07:40
· 121 commits to main since this release
fc58ecb

Tokens can now record the furthest error, here is short example how to retrieve it:

var token = parser.TryMatchToken("value", invalidJson);
var lastErrorGroup = token.Context.CreateErrorGroups().Last!;

Console.WriteLine(lastErrorGroup.FormattedLineText);
// Prints:
//     "tags": ["tag1", "tag2", "tag3"],,
//                  (line 5, column 35) ^

int column = lastErrorGroup.Column;
int line = lastErrorGroup.Line;

Also, if you want to record deep token errors when parsing rules, you need to apply this flag:

builder.Settings.RecordTokenErrors();