Skip to main content

redis_server_wrapper/
error.rs

1//! Error types for redis-server-wrapper.
2
3use std::io;
4
5/// Errors returned by redis-server-wrapper operations.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    /// A `redis-server` process failed to start.
9    #[error("redis-server failed to start on port {port}")]
10    ServerStart { port: u16 },
11
12    /// A sentinel process failed to start.
13    #[error("sentinel failed to start on port {port}")]
14    SentinelStart { port: u16 },
15
16    /// `redis-cli --cluster create` failed.
17    #[error("cluster create failed:\nstdout: {stdout}\nstderr: {stderr}")]
18    ClusterCreate { stdout: String, stderr: String },
19
20    /// A `redis-cli` command failed.
21    #[error("redis-cli {host}:{port} failed: {detail}")]
22    Cli {
23        host: String,
24        port: u16,
25        detail: String,
26    },
27
28    /// A wait-for-ready or wait-for-healthy call timed out.
29    #[error("{message}")]
30    Timeout { message: String },
31
32    /// No sentinel was reachable.
33    #[error("no reachable sentinel")]
34    NoReachableSentinel,
35
36    /// A required binary was not found on PATH.
37    #[error("{binary} not found on PATH")]
38    BinaryNotFound { binary: String },
39
40    /// An underlying I/O error.
41    #[error(transparent)]
42    Io(#[from] io::Error),
43}
44
45/// Convenience alias used throughout the crate.
46pub type Result<T> = std::result::Result<T, Error>;