zinit_client/
error.rs

1use std::io;
2use std::time::Duration;
3use thiserror::Error;
4
5/// Custom error types for the Zinit client
6#[derive(Debug, Error)]
7pub enum ZinitError {
8    /// Error connecting to the Zinit socket
9    #[error("Connection error: {0}")]
10    ConnectionError(#[from] io::Error),
11
12    /// Error in the Zinit protocol
13    #[error("Protocol error: {0}")]
14    ProtocolError(String),
15
16    /// Error from the Zinit service
17    #[error("Service error: {0}")]
18    ServiceError(String),
19
20    /// Operation timed out
21    #[error("Timeout error: operation took longer than {0:?}")]
22    TimeoutError(Duration),
23
24    /// Retry limit reached
25    #[error("Retry limit reached after {0} attempts")]
26    RetryLimitReached(usize),
27
28    /// Error parsing JSON response
29    #[error("Parse error: {0}")]
30    ParseError(#[from] serde_json::Error),
31
32    /// Unknown service
33    #[error("Unknown service: {0}")]
34    UnknownService(String),
35
36    /// Service already monitored
37    #[error("Service already monitored: {0}")]
38    ServiceAlreadyMonitored(String),
39
40    /// Service is up (can't forget)
41    #[error("Service is up: {0}")]
42    ServiceIsUp(String),
43
44    /// Service is down (can't kill)
45    #[error("Service is down: {0}")]
46    ServiceIsDown(String),
47
48    /// Invalid signal name
49    #[error("Invalid signal name: {0}")]
50    InvalidSignal(String),
51
52    /// System is shutting down
53    #[error("System is shutting down")]
54    ShuttingDown,
55}
56
57/// Result type for Zinit client operations
58pub type Result<T> = std::result::Result<T, ZinitError>;