-
Notifications
You must be signed in to change notification settings - Fork 42
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 messages are incomplete #52
Comments
At the moment error messages only report file position when the error is during parsing rather than deserialisation. It probably would be possible to include file potisions alongside the event stream that is passed to the deserialiser. |
How would you envisage the error presenting the item being deserialised - something like JSONPath? |
Would be really great to have this |
I'm stumbling over this as well right now. Something like JSONPath for showing what it's failing at would be very nice indeed, but I think that's a lot harder and a lot less important than the file position. With the file position known, the rest can be determined by the developer in some way anyway. |
There are currently a lot of places where file position and path information is lost. The solution to keep track of position would be very similar to keeping track of path so we may as well do both. What we really want to do is pass something like the following around in the place of a plain enum PathSegment<'a> {
Array(usize),
Dictionary(Cow<'a, str>),
}
struct EventWithContext<'a> {
event: Event<'a>,
position: Option<FilePosition>,
path: Option<&'a [PathSegment<'a>]>,
} |
As the event type comes from xml-rs afaict, this probably needs to touch similar code paths to the quick-xml migration, right? Is this work that's already planned more concretely, than the WIP PR over at #68? |
I mean the internal plist Line 52 in 32103bf
|
I've started toying around with this, and I can really see now why it hadn't been done previously. Things that make this unpleasant:
|
Would it be possible to use something like https://docs.rs/serde_path_to_error/latest/serde_path_to_error/ to get this for free instead? I've been trying to patch together a plist equivalent of the json example in that crate, but I can't seem to be able to pull out the right |
You want something like this:
Good find! Nice to know that |
Have similar issue when trying to deserialize from the "Bookmarks.plist" of Safari. Not sure how to debug this. |
@liebkne If this is still a problem can you open a new issue and provide the plist file you are trying to deserialise. |
thread 'main' panicked at 'failed to read settings: Error { inner: ErrorImpl { kind: UnexpectedEventType { expected: StartDictionary, found: String }, file_position: None } }', examples/settings/src/main.rs:50:30
It would be much more useful if it said which key it was trying to deserialize, and if the
file_position
was set.Using plist v1.0.0 and serde v1.0.112
The text was updated successfully, but these errors were encountered: