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

Refine exception messages in case of deserializing data from JsonElement. #2648

Merged
merged 3 commits into from
May 14, 2024

Conversation

sandwwraith
Copy link
Member

Such a code path is often used when we cannot find a type discriminator as a first key in Json (for example, if json input is invalid, and we get a string instead of an object). In such cases, we should display a nice error message.

Also, add a tag stack — the equivalent of a Json path — to most of the error messages. Note that it is far from ideal since changing between string and tree decoders (such happens in polymorphism) won't preserve stack or path correctly. Yet, it is the best we can do for now.

Fixes #2630

…ent.

Such a code path is often used when we cannot find type discriminator as a first key in Json (for example, if json input is invalid, and we got a string instead of an object). In such cases, we should display a nice error message.

Also add tag stack — equivalent of a Json path — to most of the error messages. Note that it is far from an ideal, since changing between string and tree decoders (such happens in polymorphism) won't preserve stack or path correctly. Yet, it is the best we can do for now.

Fixes #2630
@sandwwraith sandwwraith self-assigned this Apr 24, 2024
@sandwwraith sandwwraith merged commit e35c28d into dev May 14, 2024
4 checks passed
@sandwwraith sandwwraith deleted the better-json-exceptions branch May 14, 2024 12:07
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