zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.79k stars 78 forks source link

Add display line offset #124

Closed tertsdiepraam closed 3 months ago

tertsdiepraam commented 3 months ago

This is an alternative to https://github.com/zesterer/ariadne/pull/7 and also closes https://github.com/zesterer/ariadne/issues/6. I think this implementation is a bit simpler and hopefully easier to review.

To reiterate the use case. I have code like this:

#[test]
fn some_test() {
    parse_with_ariadne_errors("
       <some custom programming language here>
    ")
}

Now if ariadne prints an error for that test, I want it to give me the line number 3, not 1, because I want to know where the error is in the file, not in the string. I then automatically add the line number with a macro. I hope that makes sense. This has been super helpful for me :)

If the other implementation is preferred I could also adopt that PR and fix it up based on the feedback there.

zesterer commented 3 months ago

This seems like a useful change, thanks!

zesterer commented 3 months ago

Looks like it needs a cargo fmt before merging

tertsdiepraam commented 3 months ago

Oops! Should be fixed now!

zesterer commented 3 months ago

Thanks for the PR!

tertsdiepraam commented 3 months ago

Thanks!