summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-todo/src/util.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/domain/imag-todo/src/util.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/domain/imag-todo/src/util.rs')
-rw-r--r--bin/domain/imag-todo/src/util.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/bin/domain/imag-todo/src/util.rs b/bin/domain/imag-todo/src/util.rs
index bafd40a1..9fce60e6 100644
--- a/bin/domain/imag-todo/src/util.rs
+++ b/bin/domain/imag-todo/src/util.rs
@@ -18,11 +18,10 @@
//
use std::collections::BTreeMap;
-use std::result::Result as RResult;
-use failure::Fallible as Result;
-use failure::Error;
-use failure::err_msg;
+use anyhow::Result;
+use anyhow::Error;
+
use handlebars::Handlebars;
use clap::ArgMatches;
use chrono::NaiveDateTime;
@@ -33,8 +32,8 @@ use libimagstore::store::Entry;
use libimagtodo::entry::Todo;
use libimagutil::date::datetime_to_string;
-pub fn get_dt_str(d: Result<Option<NaiveDateTime>>, s: &str) -> RResult<String, libimagentryview::error::Error> {
- Ok(d.map_err(libimagentryview::error::Error::from)?
+pub fn get_dt_str(d: Result<Option<NaiveDateTime>>, s: &str) -> Result<String> {
+ Ok(d?
.map(|v| datetime_to_string(&v))
.unwrap_or_else(|| s.to_string()))
}
@@ -44,10 +43,10 @@ pub fn get_todo_print_format(config_value_path: &'static str, rt: &Runtime, scmd
Some(s) => Ok(s),
None => {
rt.config()
- .ok_or_else(|| err_msg("No configuration file"))?
+ .ok_or_else(|| anyhow!("No configuration file"))?
.read_string(config_value_path)
.map_err(Error::from)?
- .ok_or_else(|| format_err!("Configuration '{}' does not exist", config_value_path))
+ .ok_or_else(|| anyhow!("Configuration '{}' does not exist", config_value_path))
}
}?;