-
Notifications
You must be signed in to change notification settings - Fork 37
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
Make it easier to get a TextPos from an error #7
Comments
Thanks. Maybe it will be better to extract the TextPos from the enum completely. So pub struct Error {
pub kind: ErrorKind,
pub pos: TextPos,
} At the moment, I don't care about the |
I think that works well. If you wanted to give even more error printing control, it might also be good not to include the position in the Display implementation, because library consumers can just do |
I think that this a very rare case. And as long as there is not an official/popular pattern for error handling I think I will stick with the current one. |
Fair enough. |
Done. I've ended up using you method, because a variant with the |
Great! Thank you. |
Hi, love your work on this, I'm using it to parse CSL for a new citation processor and it's fantastic.
CSL is mostly written by hand and involves big enums of allowed attribute values, so it's important to point out when and where these mishaps happen. I use the
TextPos
embedded in each variant ofroxmltree::Error
to produce a codespan for each error, and this works well.However, it's probably better that this big match statement lives alongside its definition so other users can benefit and get the TextPos easily, and without having to update if
roxmltree
adds new variants. It would probably live onimpl Error
. Here is my source:The text was updated successfully, but these errors were encountered: