Skip to content

RUST-1874 Add optional integration with serde_path_to_error #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 30, 2024

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Jul 29, 2024

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.

@abr-egn abr-egn marked this pull request as ready for review July 29, 2024 17:21
@abr-egn abr-egn requested a review from isabelatkinson July 29, 2024 17:21
#[non_exhaustive]
WithPath {
/// The path to the error.
path: serde_path_to_error::Path,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to account for the risk of breaking changes in serde_path_to_error since we're exposing third-party API here. We could follow the -{version} name pattern that the other flags use; however, it seems like this crate has been pretty stable over the past five years so it's probably less likely that we'll need to support multiple versions of it. What do you think about just documenting this feature as "unstable" to make sure users know that any breaking changes to serde_path_to_error will affect their usage of it via this library?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, done.

@abr-egn abr-egn requested a review from isabelatkinson July 30, 2024 14:37
Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! can you also add a note somewhere in the driver docs (maybe the README/lib.rs) pointing users to this feature and showing how to enable it?

@abr-egn abr-egn merged commit a72431e into mongodb:main Jul 30, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants