Improve error reporting some more

This commit is contained in:
Dirkjan Ochtman 2022-11-29 12:15:43 +01:00
parent d5d9c60c53
commit aab73952a1
2 changed files with 3 additions and 3 deletions

View File

@ -32,7 +32,7 @@ impl<'cx, 'xml> Deserializer<'cx, 'xml> {
match self.next() {
Some(Ok(Node::AttributeValue(s))) => Ok(s),
Some(Ok(Node::Text(s))) => Ok(s),
Some(Ok(_)) => return Err(Error::ExpectedScalar),
Some(Ok(node)) => return Err(Error::ExpectedScalar(format!("{node:?}"))),
Some(Err(e)) => return Err(e),
None => return Err(Error::MissingValue(&Kind::Scalar)),
}

View File

@ -114,8 +114,8 @@ pub enum Error {
UnexpectedNode(String),
#[error("unexpected state: {0}")]
UnexpectedState(&'static str),
#[error("expected scalar")]
ExpectedScalar,
#[error("expected scalar, found {0}")]
ExpectedScalar(String),
#[error("duplicate value")]
DuplicateValue,
}