fix: incorrect error type name

This commit is contained in:
naskya 2024-07-16 02:16:56 +09:00
parent eb9c47c8c8
commit bc82dc6b41
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -169,9 +169,9 @@ fn derive_impl(input: syn::DeriveInput) -> syn::Result<TokenStream> {
.any(|attr| attr.path().is_ident("relax")); .any(|attr| attr.path().is_ident("relax"));
Ok(match (nested, get_generic_ty("Option", ty).is_some()) { Ok(match (nested, get_generic_ty("Option", ty).is_some()) {
(false, false) => quote! { #name: value.#name.ok_or(::relax::MissingRequiredField(stringify!(#name)))? }, (false, false) => quote! { #name: value.#name.ok_or(::relax::RequiredFieldNotSet(stringify!(#name)))? },
(false, true) => quote! { #name: value.#name }, (false, true) => quote! { #name: value.#name },
(true, false) => quote! { #name: value.#name.ok_or(::relax::MissingRequiredField(stringify!(#name)))?.try_into()? }, (true, false) => quote! { #name: value.#name.ok_or(::relax::RequiredFieldNotSet(stringify!(#name)))?.try_into()? },
(true, true) => quote! { #name: value.#name.map(|val| val.try_into()).transpose().ok().flatten() }, (true, true) => quote! { #name: value.#name.map(|val| val.try_into()).transpose().ok().flatten() },
}) })
}).collect::<syn::Result<Vec<_>>>()?; }).collect::<syn::Result<Vec<_>>>()?;
@ -211,7 +211,7 @@ fn derive_impl(input: syn::DeriveInput) -> syn::Result<TokenStream> {
} }
impl #generics ::std::convert::TryFrom<#partial #generics> for #base #generics { impl #generics ::std::convert::TryFrom<#partial #generics> for #base #generics {
type Error = ::relax::MissingRequiredField; type Error = ::relax::RequiredFieldNotSet;
fn try_from(value: #partial) -> ::std::result::Result<Self, Self::Error> { fn try_from(value: #partial) -> ::std::result::Result<Self, Self::Error> {
Ok(Self{ Ok(Self{