diff --git a/src/resolver/resolver_error.rs b/src/resolver/resolver_error.rs index 50af14dc..cf144979 100644 --- a/src/resolver/resolver_error.rs +++ b/src/resolver/resolver_error.rs @@ -1,6 +1,8 @@ use std::fmt; use std::fmt::Debug; +use crate::client::client_error::ClientError; + #[derive(thiserror::Error)] #[non_exhaustive] /// Common error type to hold errors from Resolver. @@ -22,7 +24,7 @@ pub enum ResolverError { RetriesLimitExceeded, #[error("parse response error: {0}")] - Parse(&'static str), + Parse(String), } // Debug trait implementation for `?` formatting @@ -38,3 +40,20 @@ impl Debug for ResolverError { } } } + +impl From for ResolverError { + fn from(err: ClientError) -> Self { + match err { + ClientError::Io(err) => ResolverError::Io(err), + ClientError::Message(err) => ResolverError::Message(err), + ClientError::FormatError(err) => ResolverError::Parse(err.to_string()), + ClientError::ServerFailure(err) => ResolverError::Parse(err.to_string()), + ClientError::NameError(err) => ResolverError::Parse(err.to_string()), + ClientError::NotImplemented(err) => ResolverError::Parse(err.to_string()), + ClientError::Refused(err) => ResolverError::Parse(err.to_string()), + ClientError::ResponseError(err) => ResolverError::Parse(err.to_string()), + ClientError::TemporaryError(err) => ResolverError::Parse(err.to_string()), + } + } + +}