summaryrefslogtreecommitdiffstats
path: root/ffi
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 /ffi
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 'ffi')
-rw-r--r--ffi/Cargo.toml2
-rw-r--r--ffi/src/error.rs5
-rw-r--r--ffi/src/lib.rs1
-rw-r--r--ffi/src/net.rs2
-rw-r--r--ffi/tests/c-tests.rs3
5 files changed, 5 insertions, 8 deletions
diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml
index aec51a28..7afd7f61 100644
--- a/ffi/Cargo.toml
+++ b/ffi/Cargo.toml
@@ -27,7 +27,7 @@ sequoia-openpgp = { path = "../openpgp", version = "0.15" }
sequoia-core = { path = "../core", version = "0.15" }
sequoia-store = { path = "../store", version = "0.15" }
sequoia-net = { path = "../net", version = "0.15" }
-failure = "0.1.2"
+anyhow = "1"
lazy_static = "1.0.0"
libc = "0.2.33"
memsec = "0.5.6"
diff --git a/ffi/src/error.rs b/ffi/src/error.rs
index 331bad04..26940111 100644
--- a/ffi/src/error.rs
+++ b/ffi/src/error.rs
@@ -1,6 +1,5 @@
//! Maps various errors to status codes.
-use failure;
use std::io;
extern crate sequoia_openpgp as openpgp;
@@ -10,11 +9,11 @@ pub use crate::openpgp::error::Status;
pub(crate) use crate::openpgp::error::Error;
trait FromSequoiaError<'a> {
- fn from_sequoia_error(_: &'a failure::Error) -> Status;
+ fn from_sequoia_error(_: &'a anyhow::Error) -> Status;
}
impl<'a> FromSequoiaError<'a> for Status {
- fn from_sequoia_error(e: &'a failure::Error) -> Self {
+ fn from_sequoia_error(e: &'a anyhow::Error) -> Self {
if let Some(e) = e.downcast_ref::<core::Error>() {
return match e {
&core::Error::NetworkPolicyViolation(_) =>
diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs
index 2d081c3e..ab2819ae 100644
--- a/ffi/src/lib.rs
+++ b/ffi/src/lib.rs
@@ -107,7 +107,6 @@
#![warn(missing_docs)]
-extern crate failure;
#[macro_use]
extern crate lazy_static;
extern crate libc;
diff --git a/ffi/src/net.rs b/ffi/src/net.rs
index ae297d4b..f40de413 100644
--- a/ffi/src/net.rs
+++ b/ffi/src/net.rs
@@ -90,7 +90,7 @@ fn sq_keyserver_with_cert(ctx: *mut Context,
};
let cert = ffi_try!(Certificate::from_der(cert)
- .map_err(|e| ::failure::Error::from(e)));
+ .map_err(|e| ::anyhow::Error::from(e)));
ffi_try_box!(KeyServer::with_cert(&ctx.c, &uri, cert))
}
diff --git a/ffi/tests/c-tests.rs b/ffi/tests/c-tests.rs
index 934bd9be..afe91c2e 100644
--- a/ffi/tests/c-tests.rs
+++ b/ffi/tests/c-tests.rs
@@ -1,5 +1,4 @@
-extern crate failure;
-use failure::{Fallible as Result, ResultExt};
+use anyhow::{Result, Context};
extern crate filetime;
use std::cmp::min;