1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-02-12 15:45:33 +01:00
2021-11-29 23:53:06 +00:00

37 lines
937 B
Rust

use std::{error::Error, io};
use derive_more::Display;
/// Errors that can result from using a connector service.
#[derive(Debug, Display)]
pub enum ConnectError {
/// Failed to resolve the hostname
#[display(fmt = "Failed resolving hostname")]
Resolver(Box<dyn std::error::Error>),
/// No DNS records
#[display(fmt = "No DNS records found for the input")]
NoRecords,
/// Invalid input
InvalidInput,
/// Unresolved host name
#[display(fmt = "Connector received `Connect` method with unresolved host")]
Unresolved,
/// Connection IO error
#[display(fmt = "{}", _0)]
Io(io::Error),
}
impl Error for ConnectError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
Self::Resolver(err) => Some(&**err),
Self::Io(err) => Some(err),
Self::NoRecords | Self::InvalidInput | Self::Unresolved => None,
}
}
}