2023-03-25 00:29:14 +08:00
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
|
|
pub enum Error {
|
2023-03-25 21:12:41 +01:00
|
|
|
#[error("std::ffi::NulError {0:?}")]
|
|
|
|
Nul(#[from] std::ffi::NulError),
|
|
|
|
|
2023-09-26 18:25:59 +08:00
|
|
|
#[error(transparent)]
|
2023-03-25 13:07:39 +01:00
|
|
|
Io(#[from] std::io::Error),
|
2023-03-22 22:19:00 +08:00
|
|
|
|
2024-10-26 02:15:52 +08:00
|
|
|
#[cfg(unix)]
|
2024-04-03 14:26:46 +00:00
|
|
|
#[error("nix::errno::Errno {0:?}")]
|
|
|
|
NixErrno(#[from] nix::errno::Errno),
|
|
|
|
|
2023-08-22 15:24:05 +08:00
|
|
|
#[error("TryFromIntError {0:?}")]
|
|
|
|
TryFromInt(#[from] std::num::TryFromIntError),
|
|
|
|
|
2023-03-25 00:29:14 +08:00
|
|
|
#[error("std::net::AddrParseError {0}")]
|
2023-03-25 13:07:39 +01:00
|
|
|
AddrParse(#[from] std::net::AddrParseError),
|
2023-03-22 22:19:00 +08:00
|
|
|
|
2023-04-14 18:44:41 +08:00
|
|
|
#[error("std::str::Utf8Error {0:?}")]
|
|
|
|
Utf8(#[from] std::str::Utf8Error),
|
|
|
|
|
2023-08-06 13:48:56 +08:00
|
|
|
#[error("TryFromSliceError {0:?}")]
|
|
|
|
TryFromSlice(#[from] std::array::TryFromSliceError),
|
|
|
|
|
2024-02-01 19:15:32 +08:00
|
|
|
#[error("IpStackError {0:?}")]
|
|
|
|
IpStack(#[from] ipstack::IpStackError),
|
|
|
|
|
|
|
|
#[error("DnsProtoError {0:?}")]
|
2025-03-19 08:36:29 +08:00
|
|
|
DnsProto(#[from] hickory_proto::ProtoError),
|
2024-02-01 19:15:32 +08:00
|
|
|
|
|
|
|
#[error("httparse::Error {0:?}")]
|
|
|
|
Httparse(#[from] httparse::Error),
|
|
|
|
|
|
|
|
#[error("digest_auth::Error {0:?}")]
|
|
|
|
DigestAuth(#[from] digest_auth::Error),
|
2023-08-06 13:48:56 +08:00
|
|
|
|
2023-04-14 18:44:41 +08:00
|
|
|
#[cfg(target_os = "android")]
|
|
|
|
#[error("jni::errors::Error {0:?}")]
|
|
|
|
Jni(#[from] jni::errors::Error),
|
|
|
|
|
2023-07-21 14:42:55 +08:00
|
|
|
#[error("{0}")]
|
2023-03-25 00:29:14 +08:00
|
|
|
String(String),
|
|
|
|
|
2023-04-01 02:19:20 +02:00
|
|
|
#[error("std::num::ParseIntError {0:?}")]
|
|
|
|
IntParseError(#[from] std::num::ParseIntError),
|
2023-03-24 09:27:31 +08:00
|
|
|
}
|
|
|
|
|
2023-03-22 22:19:00 +08:00
|
|
|
impl From<&str> for Error {
|
|
|
|
fn from(err: &str) -> Self {
|
2023-07-21 14:42:55 +08:00
|
|
|
Self::String(err.to_string())
|
2023-03-22 22:19:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<String> for Error {
|
|
|
|
fn from(err: String) -> Self {
|
2023-03-25 00:29:14 +08:00
|
|
|
Self::String(err)
|
2023-03-22 22:19:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<&String> for Error {
|
|
|
|
fn from(err: &String) -> Self {
|
2023-07-21 14:42:55 +08:00
|
|
|
Self::String(err.to_string())
|
2023-03-22 22:19:00 +08:00
|
|
|
}
|
|
|
|
}
|
2023-07-21 14:42:55 +08:00
|
|
|
|
2023-09-26 18:25:59 +08:00
|
|
|
impl From<Error> for std::io::Error {
|
|
|
|
fn from(err: Error) -> Self {
|
|
|
|
match err {
|
|
|
|
Error::Io(err) => err,
|
|
|
|
_ => std::io::Error::new(std::io::ErrorKind::Other, err),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-12 21:36:18 +08:00
|
|
|
pub type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;
|
|
|
|
|
2023-07-21 14:42:55 +08:00
|
|
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|