-
Notifications
You must be signed in to change notification settings - Fork 11
/
error.rs
104 lines (80 loc) · 3.09 KB
/
error.rs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use crate::product_config_utils;
use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Failed to serialize YAML: {source}")]
YamlSerializationError {
#[from]
source: serde_yaml::Error,
},
#[error("Failed to process YAML document: {message}")]
UnsupportedYamlDocumentError { message: String },
#[error("Kubernetes reported error: {source}")]
KubeError {
#[from]
source: kube::Error,
},
#[error("Object is missing key: {key}")]
MissingObjectKey { key: &'static str },
#[error("Label is missing: {label}")]
MissingLabel { label: &'static str },
#[error(
"Label contains unexpected content. \
Expected: {label}={expected_content}, \
actual: {label}={actual_content}"
)]
UnexpectedLabelContent {
label: &'static str,
expected_content: String,
actual_content: String,
},
#[error("LabelSelector is invalid: {message}")]
InvalidLabelSelector { message: String },
#[error("Role [{role}] is missing. This should not happen. Will requeue.")]
MissingRole { role: String },
#[error("RoleGroup [{role_group}] for Role [{role}] is missing. This may happen after custom resource changes. Will requeue.")]
MissingRoleGroup { role: String, role_group: String },
#[error(
"A required File is missing. Not found in any of the following locations: {search_path:?}"
)]
RequiredFileMissing { search_path: Vec<PathBuf> },
#[error("Failed to load ProductConfig: {source}")]
ProductConfigLoadError {
#[source]
source: product_config::error::Error,
},
#[error("ProductConfig Framework reported error: {source}")]
ProductConfigError {
#[from]
source: product_config_utils::ConfigError,
},
#[error("IO Error: {source}")]
IoError {
#[from]
source: std::io::Error,
},
#[error("Error converting CRD byte array to UTF-8")]
CrdFromUtf8Error(#[source] std::string::FromUtf8Error),
#[error("Missing OPA connect string in configmap [{configmap_name}]")]
MissingOpaConnectString { configmap_name: String },
#[error("Missing S3 connection [{name}]")]
MissingS3Connection { name: String },
#[error("Missing S3 bucket [{name}]")]
MissingS3Bucket { name: String },
#[error("Invalid quantity [{value}]")]
InvalidQuantity { value: String },
#[error("Invalid quantity unit [{value}]")]
InvalidQuantityUnit { value: String },
#[error("No quantity unit provided for [{value}]")]
NoQuantityUnit { value: String },
#[error("Cannot convert quantity [{value}] to Java heap.")]
CannotConvertToJavaHeap { value: String },
#[error("Cannot convert quantity [{value}] to Java heap value with unit [{target_unit}].")]
CannotConvertToJavaHeapValue { value: String, target_unit: String },
#[error("container name {container_name:?} is invalid: {violation}")]
InvalidContainerName {
container_name: String,
violation: String,
},
}
pub type OperatorResult<T> = std::result::Result<T, Error>;