You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
toml provides toml::de::Error with a line_col() method that works for some errors, but not all of them (like, if I put a number instead of a string somewhere, I won't have position info) https://docs.rs/toml/0.4.5/toml/de/struct.Error.html
Could we have a trait that those crates could implement, that would provide position information for errors? And possibly, not only as a line and column, but as a span (so we can show "the issue is from here to there")
The text was updated successfully, but these errors were encountered:
There would need to be a compelling real use case that benefits from having a trait for this.
I would note that just the opportunity for consistency is not enough reason to have a trait. For example Vec and VecDeque and HashMap all have a fn reserve(&mut self, additional: usize) but it doesn't mean there needs to be a trait involved.
Closing because I don't think an error position trait would carry its weight, but it would be nice to get the other formats changed to be more consistent with serde_json.
Hello,
For a bit of context, I've added to one of my projects an error display like rustc, but for toml deserialization: https://twitter.com/gcouprie/status/976117416194428930
The code for this is quite simple ( https://github.com/sozu-proxy/sozu/blob/master/command/src/config.rs#L576-L583 ), but I was surprised that there's no common trait to provide position in errors for text formats parsed with serde.
toml::de::Error
with aline_col()
method that works for some errors, but not all of them (like, if I put a number instead of a string somewhere, I won't have position info) https://docs.rs/toml/0.4.5/toml/de/struct.Error.htmlserde_yaml::Error
has alocation()
method https://docs.rs/serde_yaml/0.7.3/serde_yaml/struct.Error.htmlserde_json::Error
hasline()
andcolumn()
methods https://docs.rs/serde_json/1.0.12/serde_json/struct.Error.htmlCould we have a trait that those crates could implement, that would provide position information for errors? And possibly, not only as a line and column, but as a span (so we can show "the issue is from here to there")
The text was updated successfully, but these errors were encountered: