Skip to content
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

add better errors from deserialize #23

Open
clux opened this issue Sep 29, 2023 · 1 comment
Open

add better errors from deserialize #23

clux opened this issue Sep 29, 2023 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@clux
Copy link
Owner

clux commented Sep 29, 2023

want to let users more easily see where deserialise errors comes from.

Ideally you can add serde_path_to_error and swap out the deserializer calls with serde_path_to_error::deserialize(deserializer)

e.g.:

# original
let value: Type = serde_json::from_str(data)?
# replacement
let deserializer = &mut serde_json::Deserializer::from_str(data);
let value: Type = serde_path_to_error::deserialize(deserializer)?

There are some uncertainties here though:

  • will this work with readers? we use BufRead generally
  • will this work with singleton_map_recursive from serde_yaml? we need this to handle yaml tags
@clux clux added enhancement New feature or request help wanted Extra attention is needed labels Sep 29, 2023
@clux
Copy link
Owner Author

clux commented Oct 27, 2023

alternative; https://github.com/eopb/serde_json_path_to_error if it implements the various wrappers (as requested in its issues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant