summaryrefslogtreecommitdiffstats
path: root/bin/core/imag-git/src/lib.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-03-07 16:04:33 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-03-08 11:43:24 +0100
commit8527d447ae2047e0d5d54cc70599a895b62a3ee0 (patch)
tree023de5d446d28c6a232308f8604e17a129ee49c7 /bin/core/imag-git/src/lib.rs
parent00aa4df88edae1d5eeb3fb365af05f95bd0de3b4 (diff)
Replace failure with anyhow in complete codebase
This patch was scripted with sed -i 's/use failure::Error/use anyhow::Error/' $(rg "use failure::Error" -l) sed -i 's/use failure::Fallible as /use anyhow::/' $(rg "use failure::Fallible" -l) sed -i 's/failure/anyhow/' $(rg "failure *=" -l) sed -i 's/format_err!/anyhow!/' $(rg "format_err!" -l) sed -i 's/use failure::ResultExt/use anyhow::Context/' $(rg "use failure::ResultExt" -l) sed -i 's/err_msg/anyhow!/' $(rg "use failure::err_msg" -l) sed -i 's/^anyhow\ *=.*$/anyhow = "1"/' $(rg "anyhow * =" -l) sed -i 's/^anyhow_derive.*//' $(rg "anyhow_derive" -l) sed -i 's/extern crate failure/extern crate anyhow/' $(rg "extern crate failure" -l) sed -i 's/.*extern crate anyhow_derive.*//' $(rg "anyhow_derive" -l) Some manual changes were added as well, so this patch was not completely scripted, but mostly. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'bin/core/imag-git/src/lib.rs')
-rw-r--r--bin/core/imag-git/src/lib.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/bin/core/imag-git/src/lib.rs b/bin/core/imag-git/src/lib.rs
index d839f986..94003d91 100644
--- a/bin/core/imag-git/src/lib.rs
+++ b/bin/core/imag-git/src/lib.rs
@@ -38,7 +38,7 @@ extern crate clap;
#[macro_use] extern crate log;
extern crate toml;
extern crate toml_query;
-#[macro_use] extern crate failure;
+#[macro_use] extern crate anyhow;
extern crate libimagrt;
extern crate libimagerror;
@@ -49,9 +49,9 @@ use std::process::Command;
use toml::Value;
use toml_query::read::TomlValueReadExt;
use clap::App;
-use failure::Fallible as Result;
-use failure::ResultExt;
-use failure::err_msg;
+use anyhow::Result;
+use anyhow::Context;
+
use libimagrt::runtime::Runtime;
use libimagrt::application::ImagApplication;
@@ -67,18 +67,18 @@ impl ImagApplication for ImagGit {
fn run(rt: Runtime) -> Result<()> {
let execute_in_store = rt
.config()
- .ok_or_else(|| err_msg("No configuration. Please use git yourself, not via imag-git"))
+ .ok_or_else(|| anyhow!("No configuration. Please use git yourself, not via imag-git"))
.context("Won't continue without configuration.")
?
.read("git.execute_in_store")
.context("Failed to read config setting 'git.execute_in_store'")
?
- .ok_or_else(|| err_msg("Missing config setting 'git.execute_in_store'"))
+ .ok_or_else(|| anyhow!("Missing config setting 'git.execute_in_store'"))
?;
let execute_in_store = match *execute_in_store {
Value::Boolean(b) => Ok(b),
- _ => Err(err_msg("Type error: 'git.execute_in_store' is not a boolean!")),
+ _ => Err(anyhow!("Type error: 'git.execute_in_store' is not a boolean!")),
}?;
let execpath = if execute_in_store {
@@ -87,7 +87,7 @@ impl ImagApplication for ImagGit {
rt.rtp().to_str()
}
.map(String::from)
- .ok_or_else(|| format_err!("Cannot parse to string: {:?}", rt.store().path()))?;
+ .ok_or_else(|| anyhow!("Cannot parse to string: {:?}", rt.store().path()))?;
let mut command = Command::new("git");
command
@@ -122,7 +122,7 @@ impl ImagApplication for ImagGit {
Ok(exit_status) => {
if !exit_status.success() {
debug!("git exited with non-zero exit code: {:?}", exit_status);
- Err(format_err!("git exited with non-zero exit code: {:?}", exit_status))
+ Err(anyhow!("git exited with non-zero exit code: {:?}", exit_status))
} else {
debug!("Successful exit!");
Ok(())
@@ -132,9 +132,9 @@ impl ImagApplication for ImagGit {
Err(e) => {
debug!("Error calling git");
Err(match e.kind() {
- ErrorKind::NotFound => err_msg("Cannot find 'git' executable"),
- ErrorKind::PermissionDenied => err_msg("No permission to execute: 'git'"),
- _ => format_err!("Error spawning: {:?}", e),
+ ErrorKind::NotFound => anyhow!("Cannot find 'git' executable"),
+ ErrorKind::PermissionDenied => anyhow!("No permission to execute: 'git'"),
+ _ => anyhow!("Error spawning: {:?}", e),
})
}
}