From 6ec8d78c48c8e8dd82812415108e2252fd652b24 Mon Sep 17 00:00:00 2001 From: Tim Oram Date: Mon, 21 Sep 2020 09:43:04 -0230 Subject: Use anyhow in the main application struct The main application struct uses String errors, which make it difficult to provide context on errors. This updates the struct to provide errors with anyhow and fixes any references that used to depend on the String errors. While working on the code, several poor usages of match have been replaced with `map_or*`, `unwrap_or*` chains. --- src/process/mod.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/process') diff --git a/src/process/mod.rs b/src/process/mod.rs index 15ccc0f..fff6794 100644 --- a/src/process/mod.rs +++ b/src/process/mod.rs @@ -118,13 +118,10 @@ impl<'r> Process<'r> { } fn exit_end(&mut self) -> Result<(), String> { - match self.git_interactive.write_file() { - Ok(_) => {}, - Err(msg) => { - self.exit_status = Some(ExitStatus::FileWriteError); - return Err(msg); - }, - } + self.git_interactive.write_file().map_err(|err| { + self.exit_status = Some(ExitStatus::FileWriteError); + err.to_string() + })?; Ok(()) } } -- cgit v1.2.3