Skip to content

Commit e9ffae5

Browse files
committed
apiserver: fix incorrect error handling
Signed-off-by: Sam Berning <bernings@amazon.com>
1 parent 1e14cec commit e9ffae5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sources/api/apiserver/src/server/controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ where
136136
let os = BottlerocketRelease::new().context(error::ReleaseDataSnafu)?;
137137

138138
// Turn into a serde Value we can manipulate.
139-
let val = serde_json::to_value(os).context(error::SettingsToJsonSnafu)?;
139+
let val = serde_json::to_value(os).expect("struct to value can't fail");
140140

141141
// Structs are Objects in serde_json, which have a map of field -> value inside. We
142142
// destructure to get it by value, instead of as_object() which gives references.
@@ -366,7 +366,7 @@ pub(crate) fn set_settings<D: DataStore>(
366366
transaction: &str,
367367
) -> Result<()> {
368368
trace!("Serializing Settings to write to data store");
369-
let settings_json = serde_json::to_value(settings).expect("struct to value can't fail");
369+
let settings_json = serde_json::to_value(settings).context(error::SettingsToJsonSnafu)?;
370370
let pairs = to_pairs_with_prefix("settings", &settings_json)
371371
.context(error::DataStoreSerializationSnafu { given: "Settings" })?;
372372
let pending = Committed::Pending {

0 commit comments

Comments
 (0)