bump deserr

This commit is contained in:
Tamo 2023-02-13 18:45:13 +01:00
parent f3b54337f9
commit 8fb7b1d10f
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
23 changed files with 137 additions and 102 deletions

View file

@ -6,6 +6,8 @@ We try to:
2. Use the correct terms depending on the format of the request (json/query param)
3. Categorise the type of the error (e.g. missing field, wrong value type, unexpected error, etc.)
*/
use std::ops::ControlFlow;
use deserr::{ErrorKind, IntoValue, ValueKind, ValuePointerRef};
use super::{DeserrJsonError, DeserrQueryParamError};
@ -129,7 +131,7 @@ impl<C: Default + ErrorCode> deserr::DeserializeError for DeserrJsonError<C> {
_self_: Option<Self>,
error: deserr::ErrorKind<V>,
location: ValuePointerRef,
) -> Result<Self, Self> {
) -> ControlFlow<Self, Self> {
let mut message = String::new();
message.push_str(&match error {
@ -175,7 +177,7 @@ impl<C: Default + ErrorCode> deserr::DeserializeError for DeserrJsonError<C> {
}
});
Err(DeserrJsonError::new(message, C::default().error_code()))
ControlFlow::Break(DeserrJsonError::new(message, C::default().error_code()))
}
}
@ -222,7 +224,7 @@ impl<C: Default + ErrorCode> deserr::DeserializeError for DeserrQueryParamError<
_self_: Option<Self>,
error: deserr::ErrorKind<V>,
location: ValuePointerRef,
) -> Result<Self, Self> {
) -> ControlFlow<Self, Self> {
let mut message = String::new();
message.push_str(&match error {
@ -268,7 +270,7 @@ impl<C: Default + ErrorCode> deserr::DeserializeError for DeserrQueryParamError<
}
});
Err(DeserrQueryParamError::new(message, C::default().error_code()))
ControlFlow::Break(DeserrQueryParamError::new(message, C::default().error_code()))
}
}

View file

@ -1,6 +1,7 @@
use std::convert::Infallible;
use std::fmt;
use std::marker::PhantomData;
use std::ops::ControlFlow;
use deserr::{DeserializeError, MergeWithError, ValuePointerRef};
@ -64,8 +65,8 @@ impl<Format, C1: Default + ErrorCode, C2: Default + ErrorCode>
_self_: Option<Self>,
other: DeserrError<Format, C2>,
_merge_location: ValuePointerRef,
) -> Result<Self, Self> {
Err(DeserrError { msg: other.msg, code: other.code, _phantom: PhantomData })
) -> ControlFlow<Self, Self> {
ControlFlow::Break(DeserrError { msg: other.msg, code: other.code, _phantom: PhantomData })
}
}
@ -74,7 +75,7 @@ impl<Format, C: Default + ErrorCode> MergeWithError<Infallible> for DeserrError<
_self_: Option<Self>,
_other: Infallible,
_merge_location: ValuePointerRef,
) -> Result<Self, Self> {
) -> ControlFlow<Self, Self> {
unreachable!()
}
}
@ -112,7 +113,7 @@ macro_rules! merge_with_error_impl_take_error_message {
_self_: Option<Self>,
other: $err_type,
merge_location: ValuePointerRef,
) -> Result<Self, Self> {
) -> ControlFlow<Self, Self> {
DeserrError::<Format, C>::error::<Infallible>(
None,
deserr::ErrorKind::Unexpected { msg: other.to_string() },

View file

@ -15,7 +15,7 @@ use std::convert::Infallible;
use std::ops::Deref;
use std::str::FromStr;
use deserr::{DeserializeError, DeserializeFromValue, MergeWithError, ValueKind};
use deserr::{DeserializeError, Deserr, MergeWithError, ValueKind};
use super::{DeserrParseBoolError, DeserrParseIntError};
use crate::error::unwrap_any;
@ -38,7 +38,7 @@ impl<T> Deref for Param<T> {
}
}
impl<T, E> DeserializeFromValue<E> for Param<T>
impl<T, E> Deserr<E> for Param<T>
where
E: DeserializeError + MergeWithError<T::Err>,
T: FromQueryParameter,