use std::io;
use std::time::Duration;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ZinitError {
#[error("Connection error: {0}")]
ConnectionError(#[from] io::Error),
#[error("Protocol error: {0}")]
ProtocolError(String),
#[error("Service error: {0}")]
ServiceError(String),
#[error("Timeout error: operation took longer than {0:?}")]
TimeoutError(Duration),
#[error("Retry limit reached after {0} attempts")]
RetryLimitReached(usize),
#[error("Parse error: {0}")]
ParseError(#[from] serde_json::Error),
#[error("Unknown service: {0}")]
UnknownService(String),
#[error("Service already monitored: {0}")]
ServiceAlreadyMonitored(String),
#[error("Service is up: {0}")]
ServiceIsUp(String),
#[error("Service is down: {0}")]
ServiceIsDown(String),
#[error("Invalid signal name: {0}")]
InvalidSignal(String),
#[error("System is shutting down")]
ShuttingDown,
#[error("Feature not supported: {0}")]
FeatureNotSupported(String),
#[error("Protocol detection failed: {0}")]
ProtocolDetectionFailed(String),
#[error("JSON-RPC error (code {code}): {message}")]
JsonRpcError {
code: i32,
message: String,
data: Option<serde_json::Value>,
},
}
pub type Result<T> = std::result::Result<T, ZinitError>;