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 /bin/domain/imag-diary/src/util.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 'bin/domain/imag-diary/src/util.rs')
-rw-r--r-- | bin/domain/imag-diary/src/util.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/bin/domain/imag-diary/src/util.rs b/bin/domain/imag-diary/src/util.rs index 4a78adec..ce453358 100644 --- a/bin/domain/imag-diary/src/util.rs +++ b/bin/domain/imag-diary/src/util.rs @@ -18,13 +18,11 @@ // use libimagrt::runtime::Runtime; -use libimagerror::errors::ErrorMsg as EM; use toml::Value; use toml_query::read::TomlValueReadExt; -use failure::Error; -use failure::Fallible as Result; -use failure::ResultExt; +use anyhow::Error; +use anyhow::Result; pub fn get_diary_name(rt: &Runtime) -> Option<String> { use libimagdiary::config::get_default_diary_name; @@ -61,7 +59,6 @@ pub fn get_diary_timed_config(rt: &Runtime, diary_name: &str) -> Result<Option<T Some(cfg) => { let v = cfg .read(&format!("diary.diaries.{}.timed", diary_name)) - .context(EM::IO) .map_err(Error::from); match v { @@ -69,7 +66,7 @@ pub fn get_diary_timed_config(rt: &Runtime, diary_name: &str) -> Result<Option<T Ok(Some(_)) => { let s = format!("Type error at 'diary.diaryies.{}.timed': should be either 'd'/'daily', 'h'/'hourly', 'm'/'minutely' or 's'/'secondly'", diary_name); - Err(format_err!("{}", s)) + Err(anyhow!("{}", s)) }, Ok(None) => Ok(None), @@ -89,6 +86,6 @@ pub fn parse_timed_string(s: &str, diary_name: &str) -> Result<Timed> { } else if s == "s" || s == "secondly" { Ok(Timed::Secondly) } else { - Err(format_err!("Cannot parse config: 'diary.diaries.{}.timed = {}'", diary_name, s)) + Err(anyhow!("Cannot parse config: 'diary.diaries.{}.timed = {}'", diary_name, s)) } } |