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

Add section name in Required exception message #5

Open
canro91 opened this issue Jul 20, 2021 · 0 comments
Open

Add section name in Required exception message #5

canro91 opened this issue Jul 20, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@canro91
Copy link
Owner

canro91 commented Jul 20, 2021

Now, Required exception message only shows the name of the value to parse. To ease troubleshooting, Required exception message should display the section name too.

[Test]
public void Parse_RequiredAndPatternNotFound_ThrowsExceptionIncludingSectionName()
{
    var sectionName = "Key";
    var p = new Dictionary<String, IList<IParse>>
    {
        {
            sectionName,
            new List<IParse>
            {
                new Required(new ParseFromRegex(key: "Value", pattern: new Regex(@"Value:\s*(\d+)")))
            }
        }
    };

    var lines = FromText(@"
This line doesn't match");

    var parser = new Parser(p);

    var e = Assert.Throws<ArgumentNullException>(() => parser.Parse(lines));
    StringAssert.Contains(sectionName, e.Message);
}
@canro91 canro91 added the enhancement New feature or request label Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant