diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-03-07 16:04:33 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-03-08 11:43:24 +0100 |
commit | 8527d447ae2047e0d5d54cc70599a895b62a3ee0 (patch) | |
tree | 023de5d446d28c6a232308f8604e17a129ee49c7 /lib/core/libimagstore/src/storeid.rs | |
parent | 00aa4df88edae1d5eeb3fb365af05f95bd0de3b4 (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 'lib/core/libimagstore/src/storeid.rs')
-rw-r--r-- | lib/core/libimagstore/src/storeid.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/core/libimagstore/src/storeid.rs b/lib/core/libimagstore/src/storeid.rs index 3972f376..22f15734 100644 --- a/lib/core/libimagstore/src/storeid.rs +++ b/lib/core/libimagstore/src/storeid.rs @@ -26,10 +26,10 @@ use std::fmt::Error as FmtError; use std::result::Result as RResult; use std::path::Components; -use failure::ResultExt; -use failure::Fallible as Result; -use failure::err_msg; -use failure::Error; +use anyhow::Context; +use anyhow::Result; + +use anyhow::Error; use crate::store::Store; @@ -52,7 +52,7 @@ impl StoreId { debug!("Trying to get a new baseless id from: {:?}", id); if id.is_absolute() { debug!("Error: Id is absolute!"); - Err(format_err!("Store Id local part is absolute: {}", id.display())) + Err(anyhow!("Store Id local part is absolute: {}", id.display())) } else { debug!("Building Storeid object baseless"); Ok(StoreId(id)) @@ -184,11 +184,11 @@ impl<'a> StoreIdWithBase<'a> { store_part.display()); let p = full_path .strip_prefix(store_part) - .context(format_err!("Cannot strip prefix '{}' from path: '{}'", + .context(anyhow!("Cannot strip prefix '{}' from path: '{}'", store_part.display(), full_path.display())) .map_err(Error::from) - .context(err_msg("Error building Store Id from full path"))?; + .context(anyhow!("Error building Store Id from full path"))?; Ok(StoreIdWithBase(store_part, PathBuf::from(p))) } } @@ -227,7 +227,7 @@ macro_rules! module_entry_path_mod { use std::path::Path; use std::path::PathBuf; use $crate::storeid::StoreId; - use failure::Fallible as Result; + use anyhow::Result; pub fn new_id<P: AsRef<Path>>(p: P) -> Result<StoreId> { @@ -235,7 +235,7 @@ macro_rules! module_entry_path_mod { .as_ref() .to_str() .ok_or_else(|| { - format_err!("File path is not valid UTF-8: {}", p.as_ref().display()) + anyhow!("File path is not valid UTF-8: {}", p.as_ref().display()) })?; let id = format!("{}/{}", $name, path_str); |