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/src | |
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/src')
-rw-r--r-- | sqv/src/sqv.rs | 20 |
1 files changed, 3 insertions, 17 deletions
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] |