Skip to main content

crafty_client/
error.rs

1//! Client-side error type.
2
3/// Why a client request could not be completed.
4#[derive(Clone, Debug, thiserror::Error)]
5pub enum ClientError {
6    /// The client was created with no target nodes to contact.
7    #[error("no target nodes configured")]
8    NoTargets,
9    /// Every attempt exhausted without reaching a leader (an election is in
10    /// progress, or every contacted node forwarded but no leader answered).
11    #[error("no leader available after {attempts} attempt(s)")]
12    NoLeader {
13        /// How many attempts were made.
14        attempts: u32,
15    },
16    /// Every attempt exhausted without a reachable node.
17    #[error("all {attempts} attempt(s) failed; last transport error: {last}")]
18    Unreachable {
19        /// How many attempts were made.
20        attempts: u32,
21        /// The last transport error observed.
22        last: String,
23    },
24    /// A request attempt exceeded its per-attempt deadline on every try.
25    #[error("request timed out after {attempts} attempt(s)")]
26    Timeout {
27        /// How many attempts were made.
28        attempts: u32,
29    },
30    /// The cluster reported an application/processing error (returned verbatim
31    /// from the leader). Not retried — it is a definitive answer.
32    #[error("cluster error: {0}")]
33    Server(String),
34    /// A request/response body could not be encoded or decoded.
35    #[error("codec error: {0}")]
36    Codec(String),
37}