Skip to content

should serde provide a trait to standardize text position in errors? #1184

@Geal

Description

@Geal

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")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions