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),
|
|
|
|
|
|
|
|
#[error("ctrlc::Error {0:?}")]
|
2023-03-25 21:52:58 +01:00
|
|
|
InterruptHandler(#[from] ctrlc::Error),
|
2023-03-25 21:12:41 +01:00
|
|
|
|
2023-03-25 00:29:14 +08:00
|
|
|
#[error("std::io::Error {0}")]
|
2023-03-25 13:07:39 +01:00
|
|
|
Io(#[from] std::io::Error),
|
2023-03-22 22:19:00 +08:00
|
|
|
|
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-03-25 00:29:14 +08:00
|
|
|
#[error("smoltcp::iface::RouteTableFull {0:?}")]
|
|
|
|
RouteTableFull(#[from] smoltcp::iface::RouteTableFull),
|
2023-03-24 09:27:31 +08:00
|
|
|
|
2023-03-25 00:29:14 +08:00
|
|
|
#[error("smoltcp::socket::tcp::RecvError {0:?}")]
|
2023-03-25 13:07:39 +01:00
|
|
|
Recv(#[from] smoltcp::socket::tcp::RecvError),
|
2023-03-24 14:31:22 +08:00
|
|
|
|
2023-03-25 00:29:14 +08:00
|
|
|
#[error("smoltcp::socket::tcp::ListenError {0:?}")]
|
2023-03-25 13:07:39 +01:00
|
|
|
Listen(#[from] smoltcp::socket::tcp::ListenError),
|
2023-03-24 14:31:22 +08:00
|
|
|
|
2023-03-25 00:29:14 +08:00
|
|
|
#[error("smoltcp::socket::udp::BindError {0:?}")]
|
2023-03-25 13:07:39 +01:00
|
|
|
Bind(#[from] smoltcp::socket::udp::BindError),
|
2023-03-24 14:31:22 +08:00
|
|
|
|
2023-03-25 00:29:14 +08:00
|
|
|
#[error("smoltcp::socket::tcp::SendError {0:?}")]
|
2023-03-25 21:52:58 +01:00
|
|
|
Send(#[from] smoltcp::socket::tcp::SendError),
|
2023-03-24 14:31:22 +08:00
|
|
|
|
2023-04-14 18:44:41 +08:00
|
|
|
#[error("std::str::Utf8Error {0:?}")]
|
|
|
|
Utf8(#[from] std::str::Utf8Error),
|
|
|
|
|
|
|
|
#[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("nix::errno::Errno {0:?}")]
|
|
|
|
OSError(#[from] nix::errno::Errno),
|
|
|
|
|
|
|
|
#[error("std::num::ParseIntError {0:?}")]
|
|
|
|
IntParseError(#[from] std::num::ParseIntError),
|
2023-06-22 13:09:36 -04:00
|
|
|
|
|
|
|
#[error("httparse::Error {0}")]
|
|
|
|
HttpError(#[from] httparse::Error),
|
|
|
|
|
|
|
|
#[error("digest_auth::Error {0}")]
|
|
|
|
DigestAuthError(#[from] digest_auth::Error),
|
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
|
|
|
|
|
|
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|