1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use anyerror::AnyError;
use backoff_series::ParseError as BackoffParseError;
use openraft_macros::since;
/// Error variants related to configuration.
#[since]
#[derive(Debug, thiserror::Error)]
#[derive(PartialEq, Eq)]
pub enum ConfigError {
/// Failed to parse configuration from command-line arguments.
#[error("ParseError: {source} while parsing ({args:?})")]
ParseError {
/// The underlying parse error.
source: AnyError,
/// The arguments that failed to parse.
args: Vec<String>,
},
/// The min election timeout is not smaller than the max election timeout.
#[error("election timeout: min({min}) must be < max({max})")]
ElectionTimeout {
/// Minimum election timeout value.
min: u64,
/// Maximum election timeout value.
max: u64,
},
/// The `max_payload_entries` configuration must be greater than 0.
#[error("max_payload_entries must be > 0")]
MaxPayloadIs0,
/// Election timeout must be greater than heartbeat interval.
#[error("election_timeout_min({election_timeout_min}) must be > heartbeat_interval({heartbeat_interval})")]
ElectionTimeoutLTHeartBeat {
/// Minimum election timeout value.
election_timeout_min: u64,
/// Heartbeat interval value.
heartbeat_interval: u64,
},
/// Invalid snapshot policy string format.
#[error("snapshot policy string is invalid: '{invalid:?}' expect: '{syntax}'")]
InvalidSnapshotPolicy {
/// The invalid policy string provided.
invalid: String,
/// The expected syntax format.
syntax: String,
},
/// Failed to parse a number from string.
#[error("{reason} when parsing {invalid:?}")]
InvalidNumber {
/// The invalid number string.
invalid: String,
/// The reason for the parse failure.
reason: String,
},
/// Invalid backoff policy string.
///
/// See [`backoff_series::BackoffSeries::parse`] for the expected format.
#[since(version = "0.10.0")]
#[error(transparent)]
InvalidBackoff(#[from] BackoffParseError),
}