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
use thiserror::Error;
/// Error type for all Zenmanage SDK operations.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ZenmanageError {
/// The SDK was configured incorrectly.
#[error("configuration error: {0}")]
Configuration(String),
/// A flag couldn't be evaluated, for example because it doesn't exist and has no default.
#[error("evaluation error: {0}")]
Evaluation(String),
/// The rules couldn't be fetched.
#[error("failed to fetch rules: {message}")]
FetchRules {
/// What went wrong.
message: String,
/// The HTTP status, when the API answered.
status_code: Option<u16>,
},
/// The API returned something that couldn't be read.
#[error("invalid rules payload: {0}")]
InvalidRules(String),
/// A cache backend failed.
#[error("cache error: {0}")]
Cache(String),
/// A request couldn't be sent or its response couldn't be read.
#[error("network error: {0}")]
Network(String),
/// JSON couldn't be written or read.
#[error("serialization error: {0}")]
Serialization(#[from] serde_json::Error),
/// A file couldn't be read or written.
#[error("io error: {0}")]
Io(#[from] std::io::Error),
}
/// The result type returned by the SDK.
pub type Result<T> = std::result::Result<T, ZenmanageError>;