From aa3fa809befbda4c28cbc84730fbe3ef8fe23c22 Mon Sep 17 00:00:00 2001 From: Hristo Venev Date: Thu, 6 Feb 2020 15:03:29 +0100 Subject: Remove an unwrap. --- src/manager/mod.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/manager') diff --git a/src/manager/mod.rs b/src/manager/mod.rs index d4799a7..39e486c 100644 --- a/src/manager/mod.rs +++ b/src/manager/mod.rs @@ -81,14 +81,9 @@ impl Manager { } } - fn current_update(&mut self, c: &model::Config) { - let data = serde_json::to_vec(c).unwrap(); - match fileutil::update(&self.state_path, &data) { - Ok(()) => {} - Err(e) => { - eprintln!("<3>Failed to persist interface state: {}", e); - } - } + fn current_update(&mut self, c: &model::Config) -> io::Result<()> { + let data = serde_json::to_vec(c)?; + fileutil::update(&self.state_path, &data) } fn add_source(&mut self, config: config::Source) -> io::Result<()> { @@ -213,7 +208,9 @@ impl Manager { eprintln!("applying anyway"); } self.dev.apply_diff(&self.current, &config)?; - self.current_update(&config); + if let Err(e) = self.current_update(&config) { + eprintln!("<3>Failed to persist interface state: {}", e); + } self.current = config; } -- cgit