Use error variant for field duplicates

This commit is contained in:
Dirkjan Ochtman 2022-09-06 23:21:11 +02:00
parent ebc29b5761
commit 6c0cb83189
2 changed files with 4 additions and 2 deletions

View File

@ -259,7 +259,7 @@ impl Deserializer {
tokens.match_.extend(quote!(
__Elements::#enum_name => {
if #enum_name.is_some() {
panic!("duplicated value");
return Err(Error::DuplicateValue);
}
let mut nested = deserializer.nested(data);
@ -270,7 +270,7 @@ impl Deserializer {
tokens.match_.extend(quote!(
__Attributes::#enum_name => {
if #enum_name.is_some() {
panic!("duplicated value");
return Err(Error::DuplicateValue);
}
let mut nested = deserializer.for_attr(attr);

View File

@ -90,4 +90,6 @@ pub enum Error {
ExpectedScalar,
#[error("wrong namespace")]
WrongNamespace,
#[error("duplicate value")]
DuplicateValue,
}