From a7ae091ff5ec758e0d976b3969701f72b712406e Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Mon, 8 Jan 2018 23:19:29 -0500 Subject: [PATCH] Moved connection creation sooner for better error handling in IrcServer::from_config. --- src/client/server/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/server/mod.rs b/src/client/server/mod.rs index 7e6104b..166ac05 100644 --- a/src/client/server/mod.rs +++ b/src/client/server/mod.rs @@ -700,16 +700,16 @@ impl IrcServer { let (tx_incoming, rx_incoming) = oneshot::channel(); let (tx_view, rx_view) = oneshot::channel(); - let cfg = config.clone(); + let mut reactor = Core::new()?; + let handle = reactor.handle(); + // Attempting to connect here (as opposed to on the thread) allows more errors to happen + // immediately, rather than to occur as panics on the thread. In particular, non-resolving + // server names, and failed SSL setups will appear here. + let conn = reactor.run(Connection::new(&config, &handle)?)?; + let _ = thread::spawn(move || { let mut reactor = Core::new().unwrap(); - // Setting up internal processing stuffs. - let handle = reactor.handle(); - let conn = reactor - .run(Connection::new(&cfg, &handle).unwrap()) - .unwrap(); - tx_view.send(conn.log_view()).unwrap(); let (sink, stream) = conn.split();