summaryrefslogtreecommitdiffstats
path: root/src/process
diff options
context:
space:
mode:
authorTim Oram <dev@mitmaro.ca>2020-09-21 09:43:04 -0230
committerTim Oram <dev@mitmaro.ca>2020-09-21 09:54:10 -0230
commit6ec8d78c48c8e8dd82812415108e2252fd652b24 (patch)
tree18ddd8e53339f200e5dbf4b62e1dbd2b7b3fcce7 /src/process
parent7db93e38fb3e4d481139595857c15d656a8e5a55 (diff)
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.
Diffstat (limited to 'src/process')
-rw-r--r--src/process/mod.rs11
1 files changed, 4 insertions, 7 deletions
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(())
}
}