Skip to content

Fixed the error reporting for untagged enum errors#3047

Open
c0pp3rdru1d wants to merge 1 commit intoserde-rs:masterfrom
c0pp3rdru1d:improved-untagged-enum-errors
Open

Fixed the error reporting for untagged enum errors#3047
c0pp3rdru1d wants to merge 1 commit intoserde-rs:masterfrom
c0pp3rdru1d:improved-untagged-enum-errors

Conversation

@c0pp3rdru1d
Copy link
Copy Markdown

I improved error reporting for “partially untagged” enums (enums with tagged variants followed by #[serde(untagged)] fallbacks). Previously, when the tagged variants failed and deserialization fell through to the untagged variants, the tagged error was discarded and the final message could be uninformative.

This change collects the error from the initial tagged attempt and the errors from each untagged variant attempt, then combines them into a single data did not match any variant… message (unless a custom #[serde(expecting = ...)] is provided). We also added/updated test coverage for the expected error output so this diagnostic behavior doesn’t regress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant