Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccurate SyntaxErrorException exception information #68

Open
epignosisx opened this issue Aug 21, 2019 · 0 comments
Open

Inaccurate SyntaxErrorException exception information #68

epignosisx opened this issue Aug 21, 2019 · 0 comments

Comments

@epignosisx
Copy link

epignosisx commented Aug 21, 2019

I'm using the library to validate if a file is correctly formatted or not. Here is the simplified code:

public static bool Validate(string filename)
{
    try
    {
        var content = File.ReadAllText(filename);
        var yaml = new YamlStream();
        yaml.Load(new StringReader(content));
        return true;
    }
    catch(SyntaxErrorException ex)
    {
        Console.Error.WriteLine($"{filename} invalid: {ex.Start.ToString()}");
        return false;
    }
}

When I use the following content:

name: alex
 age: 1 #just one space to trigger error

The following is written to the console:

test.yaml invalid: Lin: 1, Col: 4, Chr: 15

I would expect Line number to be 2. Similarly column and char do not appear correct either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant