ppaass_v3_common/
error.rs1use ppaass_protocol::ProtocolError;
2use std::net::SocketAddr;
3use thiserror::Error;
4use tokio::time::error::Elapsed;
5use tracing::metadata::ParseLevelError;
6#[derive(Error, Debug)]
7
8pub enum CommonError {
9 #[error(transparent)]
10 Io(#[from] std::io::Error),
11 #[error("Aes crypto error: {_0}")]
12 Aes(String),
13 #[error("Rsa crypto error: {_0}")]
14 Rsa(String),
15 #[error(transparent)]
16 ParseLogLevel(#[from] ParseLevelError),
17 #[error("Can not find agent_user crypto with key: {0}")]
18 RsaCryptoNotFound(String),
19 #[error("User expired: {0}")]
20 UserExpired(String),
21 #[error("Connection exhausted: {0}")]
22 ConnectionExhausted(SocketAddr),
23 #[error(transparent)]
24 BincodeEncode(#[from] bincode::error::EncodeError),
25 #[error(transparent)]
26 BincodeDecode(#[from] bincode::error::DecodeError),
27 #[error(transparent)]
28 Protocol(#[from] ProtocolError),
29 #[error(transparent)]
30 Hyper(#[from] hyper::Error),
31 #[error(transparent)]
32 Timeout(#[from] Elapsed),
33 #[error("Other comment error happen: {0}")]
34 Other(String),
35}
36
37impl From<CommonError> for std::io::Error {
38 fn from(value: CommonError) -> Self {
39 std::io::Error::new(std::io::ErrorKind::Other, value)
40 }
41}