diff --git a/commons/zenoh-config/src/lib.rs b/commons/zenoh-config/src/lib.rs index 9c07bd16e7..53ac033506 100644 --- a/commons/zenoh-config/src/lib.rs +++ b/commons/zenoh-config/src/lib.rs @@ -623,9 +623,15 @@ impl Config { impl std::fmt::Display for Config { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let mut json = serde_json::to_value(self).unwrap(); - sift_privates(&mut json); - write!(f, "{json}") + serde_json::to_value(self) + .map(|mut json| { + sift_privates(&mut json); + write!(f, "{json}") + }) + .map_err(|e| { + _ = write!(f, "{e:?}"); + fmt::Error + })? } } @@ -1030,9 +1036,12 @@ impl<'a> serde::Deserialize<'a> for PluginsConfig { }) } } + impl std::fmt::Debug for PluginsConfig { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", &self.values) + let mut values: Value = self.values.clone(); + sift_privates(&mut values); + write!(f, "{:?}", values) } }