-
Notifications
You must be signed in to change notification settings - Fork 12
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
Error tweaks #209
Error tweaks #209
Conversation
So the general pattern is, provide specific error types for some things and then wrap them with a path in the top-level |
With this branch, changing a content.plist file entry to intentionally point nowhere, I now get
That's better. The path implicitly also includes the layer name, though it could be presented a bit nicer maybe 🤔 |
Also, this makes the Error::ParseError variant redundant. Maybe I can even get rid of Error::IoError? |
This is a function of the code's "separation of concerns": the glyph parsing code does not know the path, it just receives a pointer to some bytes. This means that whatever error it returns cannot include the path, so we have to add that information later. If the glif parsing code did happen to know the path, this would be unnecessary, and I would include the path in the error there. I'm not advocating this, though, since the separation of concerns is good for any number of reasons: as a simple example it means that we can test glyph parsing without needing to worry about having the files written to disk. |
This also removes the 'position' param from these errors, since it was both not very helpful and not very accurate. It would be nice to be able to do better error reporting of this stuff, but quick_xml doesn't really expose enough info to be useful.
The read/write split might not be strictly necessary, but doesn't hurt. Tracking the path feels like a good addition.
okay, fixed up and rebased :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't approve this since I opened it, but I'm happy to merge. :)
Approved it for you 😁 |
With this patch, we now track the path involved anytime we fail to load a
.glif
or a.plist
file.This also removes the position tracking for errors that occur when parsing glifs; there isn't a great way to get this information from
quick_xml
, and the information we did have was often inaccurate enough that it wasn't even on the correct line, which made it not very helpful for producing diagnostics.@madig if you're interested in adding path information to other errors, I think you should be able to follow the pattern I've used here.