summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2019-04-10 13:46:02 +0200
committerLinus Färnstrand <linus@mullvad.net>2019-04-10 13:46:02 +0200
commit76a6fe47f53415b6875d8b2932b7907893b83b67 (patch)
tree4269bea3146dfa082fe8e71dd0857e64c4dbf6ee
parent0554f71fe0c0416129f943a9ffa2da8823dee2ec (diff)
downloadmullvadvpn-76a6fe47f53415b6875d8b2932b7907893b83b67.tar.xz
mullvadvpn-76a6fe47f53415b6875d8b2932b7907893b83b67.zip
Map an error instead of panicing when starting tokio runtime
-rw-r--r--talpid-ipc/src/lib.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/talpid-ipc/src/lib.rs b/talpid-ipc/src/lib.rs
index 21c0b030f4..3e1e3790df 100644
--- a/talpid-ipc/src/lib.rs
+++ b/talpid-ipc/src/lib.rs
@@ -25,6 +25,9 @@ pub enum Error {
#[error(display = "Unable to start IPC server")]
StartServerError(#[error(cause)] io::Error),
+ #[error(display = "IPC server thread panicked and never returned a start result")]
+ ServerThreadPanicError,
+
#[error(display = "Error in IPC server")]
IpcServerError(#[error(cause)] io::Error),
@@ -65,7 +68,7 @@ impl IpcServer {
thread::spawn(move || tokio::run(fut));
start
.wait()
- .expect("server panicked")
+ .map_err(|_cancelled| Error::ServerThreadPanicError)?
.map(Err)
.unwrap_or_else(|| Ok(server))
.map_err(Error::IpcServerError)