From 3a8dc8da2dc0efebdddb0c9de6d7edbfec4106d8 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Fri, 17 Sep 2021 22:00:43 +0800 Subject: [PATCH] [xml (rust)] Log invalid attribute name --- src/xml.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/xml.rs b/src/xml.rs index 2b617bf..722d70c 100644 --- a/src/xml.rs +++ b/src/xml.rs @@ -32,8 +32,14 @@ pub fn bool_val(kv: &Attribute) -> anyhow::Result { Ok(n) } -pub fn bad_attr(tag: &str, _attr: &[u8]) -> anyhow::Result { - Err(anyhow!("unknown attribute in tag '{}'", tag)) +pub fn bad_attr(tag: &str, attr: &[u8]) -> anyhow::Result { + Err(anyhow!( + "unknown attribute {}in tag '{}'", + std::str::from_utf8(attr) + .map(|s| format!("'{}' ", s)) + .unwrap_or_default(), + tag + )) } pub fn check_attr(tag: &str, name: &str, maybe_v: Option) -> anyhow::Result {