Skip to content

Commit 1e4cffe

Browse files
committed
Use typed Key in errors
1 parent 41ce00e commit 1e4cffe

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

crates/stackable-operator/src/kvp/key.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,10 @@ impl Display for Key {
109109
}
110110
}
111111

112-
impl From<&Key> for String {
112+
// Allows SNAFU context selectors to clone the key implicitly
113+
impl From<&Key> for Key {
113114
fn from(value: &Key) -> Self {
114-
value.to_string()
115+
value.clone()
115116
}
116117
}
117118

crates/stackable-operator/src/kvp/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ where
3838
InvalidKey { source: KeyError, key: String },
3939

4040
/// Indicates that the value failed to parse.
41-
#[snafu(display("failed to parse value {value:?} of key {key:?}"))]
42-
InvalidValue {
43-
source: E,
44-
key: String,
45-
value: String,
46-
},
41+
#[snafu(display("failed to parse value {value:?} for key {key:?}", key = key.to_string()))]
42+
InvalidValue { source: E, key: Key, value: String },
4743
}
4844

4945
/// A validated Kubernetes key/value pair.

0 commit comments

Comments
 (0)