From a206235113bdb10e0d971c83f070dcf83875c47e Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 5 Mar 2020 16:38:37 +0100 Subject: store: Define store::Error using thiserror. --- store/Cargo.toml | 1 + store/src/lib.rs | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 16 deletions(-) (limited to 'store') diff --git a/store/Cargo.toml b/store/Cargo.toml index 45e73498..d56bf09d 100644 --- a/store/Cargo.toml +++ b/store/Cargo.toml @@ -36,6 +36,7 @@ failure = "0.1.2" futures = "0.1.17" rand = { version = "0.7", default-features = false } rusqlite = "0.19" +thiserror = "1" tokio-core = "0.1.10" tokio-io = "0.1.4" diff --git a/store/src/lib.rs b/store/src/lib.rs index 5a1ea2d9..b6046148 100644 --- a/store/src/lib.rs +++ b/store/src/lib.rs @@ -53,7 +53,6 @@ extern crate capnp; #[macro_use] extern crate capnp_rpc; -#[macro_use] extern crate failure; extern crate futures; extern crate rand; @@ -1180,37 +1179,31 @@ impl From for failure::Error { } } -#[derive(Fail, Debug)] +#[derive(thiserror::Error, Debug)] /// Errors returned from the store. pub enum Error { /// A requested key was not found. - #[fail(display = "Key not found")] + #[error("Key not found")] NotFound, /// The new key is in conflict with the current key. - #[fail(display = "New key conflicts with the current key")] + #[error("New key conflicts with the current key")] Conflict, /// This is a catch-all for unspecified backend errors, and should /// go away soon. - #[fail(display = "Unspecified store error")] + #[error("Unspecified store error")] StoreError, /// A protocol error occurred. - #[fail(display = "Unspecified protocol error")] + #[error("Unspecified protocol error")] ProtocolError, /// A Cert is malformed. - #[fail(display = "Malformed Cert")] + #[error("Malformed Cert")] MalformedCert, /// A fingerprint is malformed. - #[fail(display = "Malformed fingerprint")] + #[error("Malformed fingerprint")] MalformedFingerprint, /// A `capnp::Error` occurred. - #[fail(display = "Internal RPC error")] - RpcError(capnp::Error), -} - -impl From for Error { - fn from(error: capnp::Error) -> Self { - Error::RpcError(error) - } + #[error("Internal RPC error")] + RpcError(#[from] capnp::Error), } impl From for Error { -- cgit v1.2.3