summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-03-09 11:42:45 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-03-09 18:09:50 +0100
commit391a4b92c977cd64dfd131f3e29b0bc8d756d064 (patch)
treeb5b96ff935853cef9ee22e01890c248a791e724e /store
parent58d662c6d37dd1b0dccd4d0ce30290b8ede408e9 (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 'store')
-rw-r--r--store/Cargo.toml2
-rw-r--r--store/src/backend/mod.rs7
-rw-r--r--store/src/lib.rs5
-rw-r--r--store/src/macros.rs12
4 files changed, 12 insertions, 14 deletions
diff --git a/store/Cargo.toml b/store/Cargo.toml
index d56bf09d..a54a6008 100644
--- a/store/Cargo.toml
+++ b/store/Cargo.toml
@@ -30,9 +30,9 @@ sequoia-openpgp = { path = "../openpgp", version = "0.15" }
sequoia-core = { path = "../core", version = "0.15" }
sequoia-ipc = { path = "../ipc", version = "0.15" }
sequoia-net = { path = "../net", version = "0.15" }
+anyhow = "1"
capnp = "0.10"
capnp-rpc = "0.10"
-failure = "0.1.2"
futures = "0.1.17"
rand = { version = "0.7", default-features = false }
rusqlite = "0.19"
diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs
index 8141a965..342a14c4 100644
--- a/store/src/backend/mod.rs
+++ b/store/src/backend/mod.rs
@@ -1,6 +1,5 @@
//! Storage backend.
-use failure;
use std::cmp;
use std::fmt;
use std::io;
@@ -920,7 +919,7 @@ impl KeyServer {
/// Updates the key that was least recently updated.
fn update(c: &Rc<Connection>,
network_policy: core::NetworkPolicy)
- -> Box<dyn Future<Item=Duration, Error=failure::Error> + 'static> {
+ -> Box<dyn Future<Item=Duration, Error=anyhow::Error> + 'static> {
let (key, id, mut keyserver)
= match Self::update_helper(c, network_policy) {
Ok((key, id, keyserver)) => (key, id, keyserver),
@@ -1277,8 +1276,8 @@ impl From<rusqlite::Error> for node::Error {
}
}
-impl From<failure::Error> for node::Error {
- fn from(e: failure::Error) -> Self {
+impl From<anyhow::Error> for node::Error {
+ fn from(e: anyhow::Error) -> Self {
if let Some(e) = e.downcast_ref::<openpgp::Error>() {
return match e {
&openpgp::Error::MalformedCert(_) =>
diff --git a/store/src/lib.rs b/store/src/lib.rs
index b6046148..28ef59c4 100644
--- a/store/src/lib.rs
+++ b/store/src/lib.rs
@@ -53,7 +53,6 @@
extern crate capnp;
#[macro_use]
extern crate capnp_rpc;
-extern crate failure;
extern crate futures;
extern crate rand;
extern crate rusqlite;
@@ -1153,11 +1152,11 @@ impl Iterator for LogIter {
/* Error handling. */
/// Results for sequoia-store.
-pub type Result<T> = ::std::result::Result<T, failure::Error>;
+pub type Result<T> = ::std::result::Result<T, anyhow::Error>;
// Converts from backend errors.
-impl From<node::Error> for failure::Error {
+impl From<node::Error> for anyhow::Error {
fn from(error: node::Error) -> Self {
match error {
node::Error::Unspecified => Error::StoreError.into(),
diff --git a/store/src/macros.rs b/store/src/macros.rs
index 11d5772b..7d69ff54 100644
--- a/store/src/macros.rs
+++ b/store/src/macros.rs
@@ -21,10 +21,10 @@ macro_rules! make_request {
let r = match r {
/* The Result. */
Which::Ok(Ok(x)) => Ok(x),
- Which::Err(Ok(e)) => Err(failure::Error::from(e)),
+ Which::Err(Ok(e)) => Err(anyhow::Error::from(e)),
/* Protocol violations. */
- Which::Ok(Err(e)) => Err(failure::Error::from(e)),
- Which::Err(Err(e)) => Err(failure::Error::from(e)),
+ Which::Ok(Err(e)) => Err(anyhow::Error::from(e)),
+ Which::Err(Err(e)) => Err(anyhow::Error::from(e)),
};
Promise::ok(r)
}));
@@ -43,10 +43,10 @@ macro_rules! make_request_map {
let r = match r {
/* The Result. */
Which::Ok(Ok(x)) => $map(x),
- Which::Err(Ok(e)) => Err(failure::Error::from(e)),
+ Which::Err(Ok(e)) => Err(anyhow::Error::from(e)),
/* Protocol violations. */
- Which::Ok(Err(e)) => Err(failure::Error::from(e)),
- Which::Err(Err(e)) => Err(failure::Error::from(e)),
+ Which::Ok(Err(e)) => Err(anyhow::Error::from(e)),
+ Which::Err(Err(e)) => Err(anyhow::Error::from(e)),
};
Promise::ok(r)
}));