{"action":"opened","issue":{"url":"https://api.github.com/repos/serde-rs/serde/issues/1184","repository_url":"https://api.github.com/repos/serde-rs/serde","labels_url":"https://api.github.com/repos/serde-rs/serde/issues/1184/labels{/name}","comments_url":"https://api.github.com/repos/serde-rs/serde/issues/1184/comments","events_url":"https://api.github.com/repos/serde-rs/serde/issues/1184/events","html_url":"https://github.com/serde-rs/serde/issues/1184","id":306929432,"number":1184,"title":"should serde provide a trait to standardize text position in errors?","user":{"login":"Geal","id":119296,"avatar_url":"https://avatars0.githubusercontent.com/u/119296?v=4","gravatar_id":"","url":"https://api.github.com/users/Geal","html_url":"https://github.com/Geal","followers_url":"https://api.github.com/users/Geal/followers","following_url":"https://api.github.com/users/Geal/following{/other_user}","gists_url":"https://api.github.com/users/Geal/gists{/gist_id}","starred_url":"https://api.github.com/users/Geal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Geal/subscriptions","organizations_url":"https://api.github.com/users/Geal/orgs","repos_url":"https://api.github.com/users/Geal/repos","events_url":"https://api.github.com/users/Geal/events{/privacy}","received_events_url":"https://api.github.com/users/Geal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-20T15:58:51Z","updated_at":"2018-03-20T15:58:51Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\nFor 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\r\n\r\nThe 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.\r\n\r\n- 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\r\n- `serde_yaml::Error` has a `location()` method https://docs.rs/serde_yaml/0.7.3/serde_yaml/struct.Error.html\r\n- `serde_json::Error` has `line()` and `column()` methods https://docs.rs/serde_json/1.0.12/serde_json/struct.Error.html\r\n\r\nCould 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\")"}}
{"actor":{"display_login":"Geal"}}