1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-02-12 19:05:32 +01:00

37 lines
937 B
Rust
Raw Normal View History

use std::{error::Error, io};
2019-03-13 12:40:11 -07:00
use derive_more::Display;
2019-03-13 12:40:11 -07:00
/// Errors that can result from using a connector service.
#[derive(Debug, Display)]
2019-03-13 12:40:11 -07:00
pub enum ConnectError {
/// Failed to resolve the hostname
#[display(fmt = "Failed resolving hostname")]
Resolver(Box<dyn std::error::Error>),
2019-03-13 12:40:11 -07:00
/// No DNS records
#[display(fmt = "No DNS records found for the input")]
2019-03-13 12:40:11 -07:00
NoRecords,
/// Invalid input
InvalidInput,
/// Unresolved host name
#[display(fmt = "Connector received `Connect` method with unresolved host")]
Unresolved,
2019-03-13 12:40:11 -07:00
/// Connection IO error
2019-03-13 12:40:11 -07:00
#[display(fmt = "{}", _0)]
2019-03-13 14:38:33 -07:00
Io(io::Error),
2019-03-13 12:40:11 -07:00
}
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,
}
}
}