fix(error): address deserialize errors include origin
This commit is contained in:
parent
89bca64d23
commit
a72b871185
1 changed files with 13 additions and 5 deletions
|
@ -52,10 +52,12 @@ impl Address {
|
||||||
)?)),
|
)?)),
|
||||||
b'A' => Ok(Self::Attribute(String::from_utf8(digest_content)?)),
|
b'A' => Ok(Self::Attribute(String::from_utf8(digest_content)?)),
|
||||||
b'X' => Ok(Self::Url(String::from_utf8(digest_content)?)),
|
b'X' => Ok(Self::Url(String::from_utf8(digest_content)?)),
|
||||||
_ => Err(anyhow!("Unknown identity marker.")),
|
_ => Err(anyhow!("Error decoding address: Unknown identity marker.")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(anyhow!("Unknown hash function type.")),
|
_ => Err(anyhow!(
|
||||||
|
"Error decoding address: Unknown hash function type."
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,8 +84,10 @@ impl<'de> Visitor<'de> for AddressVisitor {
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
{
|
{
|
||||||
let bytes = b58_decode(str).map_err(de::Error::custom)?;
|
let bytes = b58_decode(str)
|
||||||
Address::decode(bytes.as_ref()).map_err(de::Error::custom)
|
.map_err(|e| de::Error::custom(format!("Error deserializing address: {}", e)))?;
|
||||||
|
Address::decode(bytes.as_ref())
|
||||||
|
.map_err(|e| de::Error::custom(format!("Error deserializing address: {}", e)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +104,11 @@ impl FromStr for Address {
|
||||||
type Err = anyhow::Error;
|
type Err = anyhow::Error;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
Address::decode(b58_decode(s)?.as_ref())
|
Address::decode(
|
||||||
|
b58_decode(s)
|
||||||
|
.map_err(|e| anyhow!("Error deserializing address: {}", e))?
|
||||||
|
.as_ref(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue