kvarn_fastcgi_client/
error.rs1use crate::meta::{ProtocolStatus, RequestType};
16
17pub type ClientResult<T> = Result<T, ClientError>;
18
19#[derive(Debug, thiserror::Error)]
20pub enum ClientError {
21 #[error(transparent)]
23 Io(#[from] tokio::io::Error),
24
25 #[error("Response not found of request id `{id}`")]
27 RequestIdNotFound { id: u16 },
28
29 #[error("Response not found of request id `{id}`")]
31 ResponseNotFound { id: u16 },
32
33 #[error("Response not found of request id `{request_type}`")]
35 UnknownRequestType { request_type: RequestType },
36
37 #[error("This app can't multiplex [CantMpxConn]; AppStatus: {app_status}")]
40 EndRequestCantMpxConn { app_status: u32 },
41
42 #[error("New request rejected; too busy [OVERLOADED]; AppStatus: {app_status}")]
45 EndRequestOverloaded { app_status: u32 },
46
47 #[error("Role value not known [UnknownRole]; AppStatus: {app_status}")]
50 EndRequestUnknownRole { app_status: u32 },
51}
52
53impl ClientError {
54 pub(crate) fn new_end_request_with_protocol_status(
55 protocol_status: ProtocolStatus, app_status: u32,
56 ) -> Self {
57 match protocol_status {
58 ProtocolStatus::CantMpxConn => ClientError::EndRequestCantMpxConn { app_status },
59 ProtocolStatus::Overloaded => ClientError::EndRequestOverloaded { app_status },
60 _ => ClientError::EndRequestUnknownRole { app_status },
61 }
62 }
63}