diff options
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/openvpn.rs | 2 | ||||
| -rw-r--r-- | talpid-ipc/Cargo.toml | 2 | ||||
| -rw-r--r-- | talpid-ipc/src/lib.rs | 43 |
5 files changed, 24 insertions, 27 deletions
diff --git a/Cargo.lock b/Cargo.lock index 76061d1a26..fc76a682b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2015,7 +2015,7 @@ version = "0.1.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "err-derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-client-core 0.5.0 (git+https://github.com/mullvad/jsonrpc-client-rs?rev=68aac55b)", "jsonrpc-client-ipc 0.5.0 (git+https://github.com/mullvad/jsonrpc-client-rs?rev=68aac55b)", diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index a6bc12f8b8..22337d3b3c 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -231,7 +231,7 @@ pub struct ManagementInterfaceServer { } impl ManagementInterfaceServer { - pub fn start<T>(tunnel_tx: IntoSender<ManagementCommand, T>) -> talpid_ipc::Result<Self> + pub fn start<T>(tunnel_tx: IntoSender<ManagementCommand, T>) -> Result<Self, talpid_ipc::Error> where T: From<ManagementCommand> + 'static + Send, { diff --git a/talpid-core/src/tunnel/openvpn.rs b/talpid-core/src/tunnel/openvpn.rs index 0d0c4a932f..d3e2b9858f 100644 --- a/talpid-core/src/tunnel/openvpn.rs +++ b/talpid-core/src/tunnel/openvpn.rs @@ -569,7 +569,7 @@ mod event_server { use uuid; /// Construct and start the IPC server with the given event listener callback. - pub fn start<L>(on_event: L) -> talpid_ipc::Result<talpid_ipc::IpcServer> + pub fn start<L>(on_event: L) -> std::result::Result<talpid_ipc::IpcServer, talpid_ipc::Error> where L: Fn(openvpn_plugin::EventType, HashMap<String, String>) + Send + Sync + 'static, { diff --git a/talpid-ipc/Cargo.toml b/talpid-ipc/Cargo.toml index e813011f37..e0838acfd5 100644 --- a/talpid-ipc/Cargo.toml +++ b/talpid-ipc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" edition = "2018" [dependencies] -error-chain = "0.12" +err-derive = "0.1.5" serde = "1.0" serde_json = "1.0" log = "0.4" diff --git a/talpid-ipc/src/lib.rs b/talpid-ipc/src/lib.rs index a84a982aa7..60192712cd 100644 --- a/talpid-ipc/src/lib.rs +++ b/talpid-ipc/src/lib.rs @@ -6,14 +6,8 @@ //! GNU General Public License as published by the Free Software Foundation, either version 3 of //! the License, or (at your option) any later version. -#![recursion_limit = "128"] - -#[macro_use] -extern crate error_chain; - - use futures::Future; -use std::thread; +use std::{io, thread}; use jsonrpc_core::{MetaIoHandler, Metadata}; use jsonrpc_ipc_server::{MetaExtractor, NoopExtractor, SecurityAttributes, Server, ServerBuilder}; @@ -24,16 +18,16 @@ use std::fmt; /// An Id created by the Ipc server that the client can use to connect to it pub type IpcServerId = String; -error_chain! { - errors { - IpcServerError { - description("Error in IPC server") - } +#[derive(err_derive::Error, Debug)] +pub enum Error { + #[error(display = "Unable to start IPC server")] + StartServerError(#[error(cause)] io::Error), - PermissionsError { - description("Unable to set permissions for IPC endpoint") - } - } + #[error(display = "Error in IPC server")] + IpcServerError(#[error(cause)] io::Error), + + #[error(display = "Unable to set permissions for IPC endpoint")] + PermissionsError(#[error(cause)] io::Error), } @@ -43,7 +37,10 @@ pub struct IpcServer { } impl IpcServer { - pub fn start<M: Metadata + Default>(handler: MetaIoHandler<M>, path: &str) -> Result<Self> { + pub fn start<M: Metadata + Default>( + handler: MetaIoHandler<M>, + path: &str, + ) -> Result<Self, Error> { Self::start_with_metadata(handler, NoopExtractor, path) } @@ -51,17 +48,17 @@ impl IpcServer { handler: MetaIoHandler<M>, meta_extractor: E, path: &str, - ) -> Result<Self> + ) -> Result<Self, Error> where M: Metadata + Default, E: MetaExtractor<M>, { - let security_attributes = SecurityAttributes::allow_everyone_create() - .chain_err(|| ErrorKind::PermissionsError)?; + let security_attributes = + SecurityAttributes::allow_everyone_create().map_err(Error::PermissionsError)?; let server = ServerBuilder::with_meta_extractor(handler, meta_extractor) .set_security_attributes(security_attributes) .start(path) - .chain_err(|| ErrorKind::IpcServerError) + .map_err(Error::StartServerError) .and_then(|(fut, start, server)| { thread::spawn(move || tokio::run(fut)); start @@ -69,7 +66,7 @@ impl IpcServer { .expect("server panicked") .map(Err) .unwrap_or_else(|| Ok(server)) - .chain_err(|| ErrorKind::IpcServerError) + .map_err(Error::IpcServerError) }) .map(|server| IpcServer { path: path.to_owned(), @@ -80,7 +77,7 @@ impl IpcServer { { use std::{fs, os::unix::fs::PermissionsExt}; fs::set_permissions(&path, PermissionsExt::from_mode(0o766)) - .chain_err(|| ErrorKind::PermissionsError)?; + .map_err(Error::PermissionsError)?; } Ok(server) } |
