@@ -189,6 +189,10 @@ impl Error {
189189 }
190190 }
191191 }
192+
193+ pub ( crate ) fn from_resolve_error ( error : trust_dns_resolver:: error:: ResolveError ) -> Self {
194+ ErrorKind :: DnsResolveError { message : error. to_string ( ) } . into ( )
195+ }
192196}
193197
194198impl < E > From < E > for Error
@@ -240,12 +244,8 @@ impl std::ops::Deref for Error {
240244#[ derive( Clone , Debug , Error ) ]
241245#[ non_exhaustive]
242246pub enum ErrorKind {
243- /// Wrapper around [`std::net::AddrParseError`](https://doc.rust-lang.org/std/net/struct.AddrParseError.html).
244- #[ error( "{0}" ) ]
245- AddrParse ( #[ from] std:: net:: AddrParseError ) ,
246-
247- /// An invalid argument was provided to a database operation.
248- #[ error( "An invalid argument was provided to a database operation: {message}" ) ]
247+ /// An invalid argument was provided.
248+ #[ error( "An invalid argument was provided: {message}" ) ]
249249 #[ non_exhaustive]
250250 ArgumentError { message : String } ,
251251
@@ -271,45 +271,19 @@ pub enum ErrorKind {
271271 #[ error( "Command failed {0}" ) ]
272272 CommandError ( CommandError ) ,
273273
274- // `trust_dns` does not implement the `Error` trait on their errors, so we have to manually
275- // implement `From` rather than using the `source annotation.
276- /// Wrapper around `trust_dns_resolver::error::ResolveError`.
277- #[ error( "{0}" ) ]
278- DnsResolve ( trust_dns_resolver:: error:: ResolveError ) ,
274+ /// An error occurred during DNS resolution.
275+ #[ error( "An error occurred during DNS resolution: {message}" ) ]
276+ #[ non_exhaustive]
277+ DnsResolveError { message : String } ,
279278
280279 #[ error( "Internal error: {message}" ) ]
281280 #[ non_exhaustive]
282281 InternalError { message : String } ,
283282
284- /// Wrapper around `webpki::InvalidDNSNameError`.
285- #[ error( "{0}" ) ]
286- InvalidDnsName ( #[ from] webpki:: InvalidDNSNameError ) ,
287-
288- /// A hostname could not be parsed.
289- #[ error( "Unable to parse hostname: {hostname}" ) ]
290- #[ non_exhaustive]
291- InvalidHostname { hostname : String } ,
292-
293283 /// Wrapper around [`std::io::Error`](https://doc.rust-lang.org/std/io/struct.Error.html).
294284 #[ error( "{0}" ) ]
295285 Io ( Arc < std:: io:: Error > ) ,
296286
297- #[ error( "No DNS results for domain {0}" ) ]
298- NoDnsResults ( StreamAddress ) ,
299-
300- /// A database operation failed to send or receive a reply.
301- #[ error( "A database operation failed to send or receive a reply: {message}" ) ]
302- #[ non_exhaustive]
303- OperationError { message : String } ,
304-
305- /// Data from a file could not be parsed.
306- #[ error( "Unable to parse {data_type} data from {file_path}" ) ]
307- #[ non_exhaustive]
308- ParseError {
309- data_type : String ,
310- file_path : String ,
311- } ,
312-
313287 /// The connection pool for a server was cleared during operation execution due to
314288 /// a concurrent error, causing the operation to fail.
315289 #[ error( "{message}" ) ]
@@ -326,22 +300,13 @@ pub enum ErrorKind {
326300 #[ non_exhaustive]
327301 ServerSelectionError { message : String } ,
328302
329- /// An error occurred during SRV record lookup.
330- #[ error( "An error occurred during SRV record lookup: {message}" ) ]
331- #[ non_exhaustive]
332- SrvLookupError { message : String } ,
333-
334303 /// The Client does not support sessions.
335304 #[ error( "Attempted to start a session on a deployment that does not support sessions" ) ]
336305 SessionsNotSupported ,
337306
338- #[ error( "{0}" ) ]
339- RustlsConfig ( #[ from] rustls:: TLSError ) ,
340-
341- /// An error occurred during TXT record lookup
342- #[ error( "An error occurred during TXT record lookup: {message}" ) ]
307+ #[ error( "{message}" ) ]
343308 #[ non_exhaustive]
344- TxtLookupError { message : String } ,
309+ TlsConfigError { message : String } ,
345310
346311 /// The Client timed out while checking out a connection from connection pool.
347312 #[ error(
@@ -355,12 +320,6 @@ pub enum ErrorKind {
355320 WriteError ( WriteFailure ) ,
356321}
357322
358- impl From < trust_dns_resolver:: error:: ResolveError > for ErrorKind {
359- fn from ( error : trust_dns_resolver:: error:: ResolveError ) -> Self {
360- Self :: DnsResolve ( error)
361- }
362- }
363-
364323impl ErrorKind {
365324 pub ( crate ) fn is_non_timeout_network_error ( & self ) -> bool {
366325 matches ! ( self , ErrorKind :: Io ( ref io_err) if io_err. kind( ) != std:: io:: ErrorKind :: TimedOut )
0 commit comments