Commit 135dd07
authored
feat(canonical): typed Error::DuplicateKey + non-exhaustive Error enum (#1741)
parse_strict already rejects duplicate object keys at every depth, but
folded that rejection into Error::Parse alongside ordinary malformed
JSON, so consumers mapping the two to distinct reason classes had to
string-match the "duplicate object key" message.
Add a distinct Error::DuplicateKey(String) carrying the offending key.
The duplicate-key signal originates as a serde custom error in
visit_map; parse_strict now classifies it at the parse boundary via a
shared marker constant, so the message is interpreted in exactly one
place and the public API exposes a clean variant. Other JSON syntax
errors still map to Error::Parse.
Mark Error #[non_exhaustive] in the same change. The crate is publishable
but not yet released, so this is the free window to do it: once a version
is on crates.io, adding a variant (or non_exhaustive itself) to the public
enum would be a breaking API change. With it, this variant and future
parse/canonicalization failure modes stay additive.
Additive within the workspace: no caller matches Error exhaustively.
Digests and goldens are untouched; duplicate keys are still rejected.
Signed-off-by: Rul1an <roelschuurkes@gmail.com>1 parent ccd66af commit 135dd07
2 files changed
Lines changed: 63 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
49 | | - | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| |||
82 | 89 | | |
83 | 90 | | |
84 | 91 | | |
85 | | - | |
| 92 | + | |
86 | 93 | | |
87 | 94 | | |
88 | 95 | | |
| |||
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
104 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
105 | 137 | | |
106 | 138 | | |
107 | 139 | | |
| |||
113 | 145 | | |
114 | 146 | | |
115 | 147 | | |
116 | | - | |
| 148 | + | |
117 | 149 | | |
118 | 150 | | |
119 | 151 | | |
120 | 152 | | |
121 | 153 | | |
122 | | - | |
123 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
124 | 171 | | |
125 | 172 | | |
126 | 173 | | |
| |||
0 commit comments