mongodb / bson-rust

Encoding and decoding support for BSON in Rust
MIT License
405 stars 134 forks source link

RUST-1874 Add optional integration with `serde_path_to_error` #488

Closed abr-egn closed 4 months ago

abr-egn commented 4 months ago

RUST-1874

Using the wrapped [de]serialization does come with a small CPU cost and a less small memory cost, so I've made this an optional feature. The user-visible API for this is a new variant for the ser::Error and de::Error types that wraps an inner error along with a path, and corresponding pretty-printed error messages for those. I'd have preferred an Error struct carrier for metadata and an ErrorKind enum here but I think this is a reasonable non-breaking solution.