[xml (rust)] Log invalid attribute name

This commit is contained in:
Ming-Hung Tsai 2021-09-17 22:00:43 +08:00
parent ed7480e96d
commit 3a8dc8da2d

View File

@ -32,8 +32,14 @@ pub fn bool_val(kv: &Attribute) -> anyhow::Result<bool> {
Ok(n)
}
pub fn bad_attr<T>(tag: &str, _attr: &[u8]) -> anyhow::Result<T> {
Err(anyhow!("unknown attribute in tag '{}'", tag))
pub fn bad_attr<T>(tag: &str, attr: &[u8]) -> anyhow::Result<T> {
Err(anyhow!(
"unknown attribute {}in tag '{}'",
std::str::from_utf8(attr)
.map(|s| format!("'{}' ", s))
.unwrap_or_default(),
tag
))
}
pub fn check_attr<T>(tag: &str, name: &str, maybe_v: Option<T>) -> anyhow::Result<T> {