diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-09-12 10:53:47 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-09-12 10:53:47 +0200 |
| commit | 2bc13231538133ad452b1b72ac4bbfe67235df02 (patch) | |
| tree | df85d3a7760214d16e4a40c286a2b579d4b76dee | |
| parent | bf85a72a067389abfee4498a07b3a2d0fa8443eb (diff) | |
| parent | 242d2c685a081e52ab3536be54554d3bb95449d5 (diff) | |
| download | mullvadvpn-2bc13231538133ad452b1b72ac4bbfe67235df02.tar.xz mullvadvpn-2bc13231538133ad452b1b72ac4bbfe67235df02.zip | |
Merge branch 'more-detailed-rpc-errors'
| -rw-r--r-- | Cargo.lock | 93 | ||||
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 12 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 33 | ||||
| -rw-r--r-- | talpid-core/Cargo.toml | 4 | ||||
| -rw-r--r-- | talpid-ipc/Cargo.toml | 6 |
5 files changed, 85 insertions, 63 deletions
diff --git a/Cargo.lock b/Cargo.lock index bcf7b00aa6..91b97a1db7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -297,14 +297,6 @@ dependencies = [ [[package]] name = "error-chain" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "error-chain" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ @@ -442,12 +434,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "jsonrpc-client-core" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 7.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 7.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -455,14 +447,14 @@ dependencies = [ [[package]] name = "jsonrpc-client-http" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-client-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -470,8 +462,8 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "7.1.0" -source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.0#a51a5265d85488c76a6ce8807d42d7dd25e94f1b" +version = "7.1.1" +source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.1#21de52aee71ce75f3ad1efee17bab11a23ddffcb" dependencies = [ "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -482,7 +474,7 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "7.1.0" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -494,32 +486,32 @@ dependencies = [ [[package]] name = "jsonrpc-macros" -version = "7.1.0" -source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.0#a51a5265d85488c76a6ce8807d42d7dd25e94f1b" +version = "7.1.1" +source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.1#21de52aee71ce75f3ad1efee17bab11a23ddffcb" dependencies = [ - "jsonrpc-core 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", - "jsonrpc-pubsub 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", + "jsonrpc-core 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", + "jsonrpc-pubsub 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-pubsub" -version = "7.1.0" -source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.0#a51a5265d85488c76a6ce8807d42d7dd25e94f1b" +version = "7.1.1" +source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.1#21de52aee71ce75f3ad1efee17bab11a23ddffcb" dependencies = [ - "jsonrpc-core 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", + "jsonrpc-core 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-server-utils" -version = "7.1.0" -source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.0#a51a5265d85488c76a6ce8807d42d7dd25e94f1b" +version = "7.1.1" +source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.1#21de52aee71ce75f3ad1efee17bab11a23ddffcb" dependencies = [ "bytes 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", + "jsonrpc-core 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -527,11 +519,11 @@ dependencies = [ [[package]] name = "jsonrpc-ws-server" -version = "7.1.0" -source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.0#a51a5265d85488c76a6ce8807d42d7dd25e94f1b" +version = "7.1.1" +source = "git+https://github.com/paritytech/jsonrpc?tag=v7.1.1#21de52aee71ce75f3ad1efee17bab11a23ddffcb" dependencies = [ - "jsonrpc-core 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", - "jsonrpc-server-utils 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", + "jsonrpc-core 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", + "jsonrpc-server-utils 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -667,12 +659,12 @@ dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "fern 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-client-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-client-http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", - "jsonrpc-macros 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", - "jsonrpc-pubsub 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", - "jsonrpc-ws-server 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", + "jsonrpc-client-core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", + "jsonrpc-macros 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", + "jsonrpc-pubsub 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", + "jsonrpc-ws-server 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mullvad-types 0.1.0", @@ -1184,8 +1176,8 @@ dependencies = [ "assert_matches 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "duct 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", - "jsonrpc-macros 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", + "jsonrpc-core 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", + "jsonrpc-macros 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1202,9 +1194,9 @@ dependencies = [ "assert_matches 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", - "jsonrpc-macros 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", - "jsonrpc-ws-server 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)", + "jsonrpc-core 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", + "jsonrpc-macros 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", + "jsonrpc-ws-server 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1502,7 +1494,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum duct 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f3154a9285e24d7c3aba0dca9a13adf2ba6160cce3490b157c8b37a0f80e85" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c858c42ac0b88532f48fca88b0ed947cad4f1f64d904bcd6c9f138f7b95d70" -"checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum fern 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89273e0d0e210f69600048a209a00e163560b51e3ef51c3942304e9b8aa8b47a" "checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" @@ -1520,14 +1511,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29d062ee61fccdf25be172e70f34c9f6efc597e1fb8f6526e8437b2046ab26be" "checksum ipnetwork 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)" = "232e76922883005380e831068f731ef0305541c9f77b30df3a1635047b16f370" "checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" -"checksum jsonrpc-client-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f21468a3d734c9b52358c06e7dda08bef647dfefa30ed1f4a78cf53e9bc0241" -"checksum jsonrpc-client-http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62a3fe12c388172dbbe749c6eb70096a8fd20c9fa32512bad5e7cccc135d5c42" -"checksum jsonrpc-core 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)" = "<none>" -"checksum jsonrpc-core 7.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "903e5eee845f3d83c1436d12848d97b1247cf850ff06a8e1db2f1ce3543af2cf" -"checksum jsonrpc-macros 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)" = "<none>" -"checksum jsonrpc-pubsub 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)" = "<none>" -"checksum jsonrpc-server-utils 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)" = "<none>" -"checksum jsonrpc-ws-server 7.1.0 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.0)" = "<none>" +"checksum jsonrpc-client-core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1abbdedae1ea039d0cd969753f25affc6f6efa94a073731595b8540649d2a587" +"checksum jsonrpc-client-http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "670cfa7e709954c403b16ba38672eb34b77e1969c250fae3dfd45bd9353deaf9" +"checksum jsonrpc-core 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)" = "<none>" +"checksum jsonrpc-core 7.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1acd0f9934da94466d2370f36832b9b19271b4abdfdb5e69f0bcd991ebcd515" +"checksum jsonrpc-macros 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)" = "<none>" +"checksum jsonrpc-pubsub 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)" = "<none>" +"checksum jsonrpc-server-utils 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)" = "<none>" +"checksum jsonrpc-ws-server 7.1.1 (git+https://github.com/paritytech/jsonrpc?tag=v7.1.1)" = "<none>" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "cf186d1a8aa5f5bee5fd662bc9c1b949e0259e1bcc379d1f006847b0080c7417" diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index 09811fddc2..786baac7a3 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -19,12 +19,12 @@ futures = "0.1" serde = "1.0" serde_derive = "1.0" log = "0.3" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } -jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } -jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } -jsonrpc-client-core = "0.2" -jsonrpc-client-http = "0.2" +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } +jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } +jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } +jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } +jsonrpc-client-core = "0.2.1" +jsonrpc-client-http = "0.2.1" uuid = { version = "0.5", features = ["v4"] } lazy_static = "0.2" toml = "0.4" diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index ab1c4deee9..bca4f68f13 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -1,5 +1,6 @@ use error_chain; +use error_chain::ChainedError; use jsonrpc_client_core; use jsonrpc_core::{Error, ErrorCode, Metadata}; use jsonrpc_core::futures::{Future, future, sync}; @@ -246,6 +247,24 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterface<T> { .map_err(|_| Error::internal_error()) ) } + + /// Converts the given error to an error that can be given to the caller of the API. + /// Will let any actual RPC error through as is, any other error is changed to an internal + /// error. + fn map_rpc_error(error: jsonrpc_client_core::Error) -> Error { + match error.kind() { + &jsonrpc_client_core::ErrorKind::JsonRpcError(ref rpc_error) => { + // We have to manually copy the error since we have different + // versions of the jsonrpc_core library at the moment. + Error { + code: ErrorCode::from(rpc_error.code.code()), + message: rpc_error.message.clone(), + data: rpc_error.data.clone(), + } + } + _ => Error::internal_error(), + } + } } impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for ManagementInterface<T> { @@ -256,7 +275,19 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem let (tx, rx) = sync::oneshot::channel(); let future = self.send_command_to_daemon(TunnelCommand::GetAccountData(tx, account_token)) .and_then(|_| rx.map_err(|_| Error::internal_error())) - .and_then(|rpc_future| rpc_future.map_err(|_| Error::internal_error())); + .and_then( + |rpc_future| { + rpc_future.map_err( + |error: jsonrpc_client_core::Error| { + error!( + "Unable to get account data from master: {}", + error.display_chain() + ); + Self::map_rpc_error(error) + }, + ) + }, + ); Box::new(future) } diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml index 3f5636c7d7..9b9cada258 100644 --- a/talpid-core/Cargo.toml +++ b/talpid-core/Cargo.toml @@ -8,8 +8,8 @@ license = "GPL-3.0" [dependencies] duct = "0.9.1" error-chain = "0.11" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } +jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } lazy_static = "0.2" log = "0.3" uuid = { version = "0.5", features = ["v4"] } diff --git a/talpid-ipc/Cargo.toml b/talpid-ipc/Cargo.toml index a8428a68d3..243c87b968 100644 --- a/talpid-ipc/Cargo.toml +++ b/talpid-ipc/Cargo.toml @@ -10,12 +10,12 @@ error-chain = "0.11" serde = "1.0" serde_json = "1.0" log = "0.3" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } -jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } +jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } ws = { git = "https://github.com/tomusdrw/ws-rs" } url = "1.4" [dev-dependencies] assert_matches = "1.0" env_logger = "0.4" -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.0" } +jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1" } |
