From aab73952a17861baf5db9898f96a5dea3dc65688 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 29 Nov 2022 12:15:43 +0100 Subject: [PATCH] Improve error reporting some more --- instant-xml/src/de.rs | 2 +- instant-xml/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/instant-xml/src/de.rs b/instant-xml/src/de.rs index 987ea94..2e40e50 100644 --- a/instant-xml/src/de.rs +++ b/instant-xml/src/de.rs @@ -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)), } diff --git a/instant-xml/src/lib.rs b/instant-xml/src/lib.rs index 3a74945..f034c54 100644 --- a/instant-xml/src/lib.rs +++ b/instant-xml/src/lib.rs @@ -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, }