Improve deserr error for unknown values

This commit is contained in:
F. Levi 2024-09-18 10:46:05 +03:00
parent e54fbb0d1e
commit f95bd11db2

View File

@ -330,8 +330,9 @@ impl<E: DeserializeError> Deserr<E> for Action {
Some(action) => Ok(action), Some(action) => Ok(action),
None => Err(deserr::take_cf_content(E::error::<std::convert::Infallible>( None => Err(deserr::take_cf_content(E::error::<std::convert::Infallible>(
None, None,
deserr::ErrorKind::Unexpected { deserr::ErrorKind::UnknownValue {
msg: format!("string must be a valid action, got {}", s), value: &s,
accepted: &Self::SERDE_MAP_ARR.map(|(ser_action, _)| ser_action),
}, },
location, location,
))), ))),