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

Give line number and column number of error instead of single location value on parse error #51

Open
Bellarmine-Head opened this issue Nov 25, 2017 · 1 comment

Comments

@Bellarmine-Head
Copy link

Bellarmine-Head commented Nov 25, 2017

This:-

fn main() {
    let xml = r#"<?xml version="1.0"?>
<bookshop>
  <books>
    <book>
      <title>The Illuminatus Trilogy</title>
    </book>
  </books>
</bookshop1>"#;

    let result = parser::parse(xml);

    match result {
        Ok(_) => println!("parsed ok"),
        Err((loc, errors)) => println!("parse failed; location = {}, errors = {:?}",
            loc, errors),
    }
}

will print:-

parse failed; location = 124, errors = [MismatchedElementEndName]

It would be nicer to give the line number and column number of the error, as all other XML parsers I've played with do.

@shepmaster
Copy link
Owner

Yep. Even better would be to copy what my other parser does and calculate the line / column and show a snippet.

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

No branches or pull requests

2 participants