Add ErrorKind::DeserializeError to specialize ErrorKind::Message (extract::path::ErrorKind) (#2720)

This commit introduces another `extract::path::ErrorKind` variant that captures the
serde error nominally captured through the `serde::de::Error` trait impl on `PathDeserializeError`.
We augment the deserialization error with the captured (key, value), allowing `extract::Path`, and wrapping
extractors, to gain programmatic access to the key name, and attempted deserialized value.

The `PathDeserializationError::custom` is used two places in addition to capture the deserialization error.
These usages should still be unaffected.

Co-authored-by: David Mládek <[email protected]>
This commit is contained in:
Vegard Sandengen
2024-11-11 16:56:25 +00:00
committed by GitHub
co-authored by David Mládek
parent 6e0559e687
commit 59a2960e42
4 changed files with 114 additions and 6 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ mod tests {
let res = client.get("/NaN").await;
assert_eq!(
res.text().await,
"Invalid URL: Cannot parse `\"NaN\"` to a `u32`"
"Invalid URL: Cannot parse `NaN` to a `u32`"
);
}
}