diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-11-23 15:42:22 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-11-23 15:42:22 +0100 |
commit | ba2a1b2d034d131c6e3c7cda6a960d71d07ae7d4 (patch) | |
tree | 3d36528257bd0f2fc5a8de9d0f7b04e441d28886 | |
parent | 14102930e660b06661ffadd047fbcf5ef88ef02f (diff) |
net: Improve the errors returned from dane::get.
-rw-r--r-- | net/src/dane.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/net/src/dane.rs b/net/src/dane.rs index cfcd164a..145fe589 100644 --- a/net/src/dane.rs +++ b/net/src/dane.rs @@ -65,8 +65,7 @@ async fn get_raw(email_address: impl AsRef<str>) -> Result<Vec<Vec<u8>>> { let answers = resolver .lookup(fqdn, RecordType::OPENPGPKEY) .await - .map_err(|e| anyhow::Error::from(crate::Error::NotFound) - .context(e.to_string()))?; + .map_err(Error::NotFound)?; let mut bytes = vec![]; @@ -349,6 +348,15 @@ fn generate_<'a>(cert: &ValidCert<'a>, fqdn: &str, ttl: Option<Duration>, Ok(records) } +/// Errors for this module. +#[derive(thiserror::Error, Debug)] +#[non_exhaustive] +pub enum Error { + /// A requested cert was not found. + #[error("Cert not found")] + NotFound(#[from] hickory_resolver::error::ResolveError), +} + #[cfg(test)] mod tests { use super::*; |