diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-03-09 11:42:45 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-03-09 18:09:50 +0100 |
commit | 391a4b92c977cd64dfd131f3e29b0bc8d756d064 (patch) | |
tree | b5b96ff935853cef9ee22e01890c248a791e724e /sqv | |
parent | 58d662c6d37dd1b0dccd4d0ce30290b8ede408e9 (diff) |
Switch from failure to anyhow.
- Use the anyhow crate instead of failure to implement the dynamic
side of our error handling. anyhow::Error derefs to dyn
std::error::Error, allowing better interoperability with other
stdlib-based error handling libraries.
- Fixes #444.
Diffstat (limited to 'sqv')
-rw-r--r-- | sqv/Cargo.toml | 3 | ||||
-rw-r--r-- | sqv/src/sqv.rs | 20 |
2 files changed, 5 insertions, 18 deletions
diff --git a/sqv/Cargo.toml b/sqv/Cargo.toml index b41f110e..13dce931 100644 --- a/sqv/Cargo.toml +++ b/sqv/Cargo.toml @@ -22,9 +22,10 @@ maintenance = { status = "actively-developed" } [dependencies] sequoia-openpgp = { path = "../openpgp", version = "0.15", default-features = false } +anyhow = "1" chrono = "0.4" clap = "2.32.0" -failure = "0.1.2" + [build-dependencies] clap = "2.27.1" diff --git a/sqv/src/sqv.rs b/sqv/src/sqv.rs index 831e9945..dfa6042b 100644 --- a/sqv/src/sqv.rs +++ b/sqv/src/sqv.rs @@ -8,8 +8,7 @@ use std::io; use chrono::{DateTime, offset::Utc}; extern crate clap; -extern crate failure; -use failure::ResultExt; +use anyhow::Context; extern crate sequoia_openpgp as openpgp; @@ -224,7 +223,7 @@ impl<'a> VerificationHelper for VHelper<'a> { } -fn real_main() -> Result<()> { +fn main() -> Result<()> { let p = &P::new(); let matches = sqv_cli::build().get_matches(); @@ -292,19 +291,6 @@ fn real_main() -> Result<()> { exit(if h.good >= good_threshold { 0 } else { 1 }); } -fn main() { - if let Err(e) = real_main() { - let mut cause = e.as_fail(); - eprint!("{}", cause); - while let Some(c) = cause.cause() { - eprint!(":\n {}", c); - cause = c; - } - eprintln!(); - exit(2); - } -} - /// Parses the given string depicting a ISO 8601 timestamp. fn parse_iso8601(s: &str, pad_date_with: chrono::NaiveTime) -> Result<DateTime<Utc>> @@ -348,7 +334,7 @@ fn parse_iso8601(s: &str, pad_date_with: chrono::NaiveTime) return Ok(DateTime::from_utc(d.and_time(pad_date_with), Utc)); } } - Err(failure::format_err!("Malformed ISO8601 timestamp: {}", s)) + Err(anyhow::anyhow!("Malformed ISO8601 timestamp: {}", s)) } #[test] |