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 #[error("Feature not supported: {0}")]
58 FeatureNotSupported(String),
59
60 #[error("Protocol detection failed: {0}")]
62 ProtocolDetectionFailed(String),
63
64 #[error("JSON-RPC error (code {code}): {message}")]
66 JsonRpcError {
67 code: i32,
69 message: String,
71 data: Option<serde_json::Value>,
73 },
74}
75
76pub type Result<T> = std::result::Result<T, ZinitError>;