Commit 7d670c2
Merge #586
586: Improve error messaged by dropping untagged enums r=jonasbb a=jonasbb
Untagged enums do not provide good error messages and likely never will,
given that there are multiple PRs which are just completely ignored
([serde#2376](serde-rs/serde#2376) and
[serde#1544](serde-rs/serde#1544)).
Instead using `content::de` the untagged enums can be replaced by custom
buffering. The error messages for `OneOrMany` and `PickFirst` now look
like this, including the original failure for each variant.
```text
OneOrMany could not deserialize any variant:
One: invalid type: map, expected u32
Many: invalid type: map, expected a sequence
```
```text
PickFirst could not deserialize any variant:
First: invalid type: string "Abc", expected u32
Second: invalid digit found in string
```
The implementations of `VecSkipError` and `DefaultOnError` are updated
too, but should not result in any visible changes.
Co-authored-by: Jonas Bushart <[email protected]>File tree
5 files changed
+237
-172
lines changed- serde_with
- src/de
- tests/serde_as
5 files changed
+237
-172
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
10 | 30 | | |
11 | 31 | | |
12 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
0 commit comments