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.
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")
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::Errorwith 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::Errorhas alocation()method https://docs.rs/serde_yaml/0.7.3/serde_yaml/struct.Error.htmlserde_json::Errorhasline()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")