actix_tls/connect/
error.rs1use std::{error::Error, fmt, io};
2
3#[derive(Debug)]
5pub enum ConnectError {
6 Resolver(Box<dyn std::error::Error>),
8
9 NoRecords,
11
12 InvalidInput,
14
15 Unresolved,
17
18 Io(io::Error),
20}
21
22impl fmt::Display for ConnectError {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 match self {
25 Self::NoRecords => f.write_str("No DNS records found for the input"),
26 Self::InvalidInput => f.write_str("Invalid input"),
27 Self::Unresolved => {
28 f.write_str("Connector received `Connect` method with unresolved host")
29 }
30 Self::Resolver(_) => f.write_str("Failed to resolve hostname"),
31 Self::Io(_) => f.write_str("I/O error"),
32 }
33 }
34}
35
36impl Error for ConnectError {
37 fn source(&self) -> Option<&(dyn Error + 'static)> {
38 match self {
39 Self::Resolver(err) => Some(&**err),
40 Self::Io(err) => Some(err),
41 Self::NoRecords | Self::InvalidInput | Self::Unresolved => None,
42 }
43 }
44}