1use std::io;
2use std::time::Duration;
3use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum ZinitError {
8 #[error("Connection error: {0}")]
10 ConnectionError(#[from] io::Error),
11
12 #[error("Protocol error: {0}")]
14 ProtocolError(String),
15
16 #[error("Service error: {0}")]
18 ServiceError(String),
19
20 #[error("Timeout error: operation took longer than {0:?}")]
22 TimeoutError(Duration),
23
24 #[error("Retry limit reached after {0} attempts")]
26 RetryLimitReached(usize),
27
28 #[error("Parse error: {0}")]
30 ParseError(#[from] serde_json::Error),
31
32 #[error("Unknown service: {0}")]
34 UnknownService(String),
35
36 #[error("Service already monitored: {0}")]
38 ServiceAlreadyMonitored(String),
39
40 #[error("Service is up: {0}")]
42 ServiceIsUp(String),
43
44 #[error("Service is down: {0}")]
46 ServiceIsDown(String),
47
48 #[error("Invalid signal name: {0}")]
50 InvalidSignal(String),
51
52 #[error("System is shutting down")]
54 ShuttingDown,
55}
56
57pub type Result<T> = std::result::Result<T, ZinitError>;