Provide more info about errors in parsing
Opened this issue · 3 comments
https://docs.rs/xot/latest/xot/enum.Error.html
There are a bunch of error variants that just have a string field without any description of what those strings contain.
The errors also lack information about the position. So, in a large enough xml file, it might take a long time to find the error. Just like xmlparser, it would be great if we had a TextPos
along with the errors.
Yeah, error reporting is definitely a flaw in Xot for now.
I've recently got to understand thiserror better, and I want to switch to that away from the handwritten struct where I mimicked roxmltree.
In addition, for error information I now have experience with miette, and we could potentially add miette span information. That way it would be also be more easy for a command-line tool that uses Xot to display nice information. But that might be overkill; if we have a text position we'd be good already, but a miette source span is effectively the same with nice facilities in addition.
What do you think?
thiserror
is definitely the way to go.
But miette
is also a cool idea. I was using color-eyre
, but i will shift to miette
too if i get to use the span info from xot
. It would be really helpful to show specific error lines of xml to users for easier debugging.
Just a note I haven't forgotten about this issue. I do intend to add span information to errors. I think I will forgo adding miette to leave the choice of reporting framework up to the user (miette, ariadne, etc).