From 0b78b316660a5546cdc3721303cb622cccd2794a Mon Sep 17 00:00:00 2001 From: Songtronix Date: Sat, 4 Jan 2020 11:21:59 +0100 Subject: [PATCH] improve(voxygen): error handling while connecting --- client/src/lib.rs | 3 +- voxygen/src/menu/main/client_init.rs | 2 +- voxygen/src/menu/main/mod.rs | 52 +++++++++++++++++++++------- voxygen/src/menu/main/ui.rs | 7 ++-- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 7e3520a606..fc85c38ff6 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -5,6 +5,7 @@ pub mod error; // Reexports pub use crate::error::Error; +pub use authc::AuthClientError; pub use specs::{ join::Join, saveload::{Marker, MarkerAllocator}, @@ -105,7 +106,7 @@ impl Client { ); } - log::info!("Auth Server: {:?}", server_info.auth_provider); + log::debug!("Auth Server: {:?}", server_info.auth_provider); // Initialize `State` let mut state = State::default(); diff --git a/voxygen/src/menu/main/client_init.rs b/voxygen/src/menu/main/client_init.rs index 04e37f6f7f..26dc674983 100644 --- a/voxygen/src/menu/main/client_init.rs +++ b/voxygen/src/menu/main/client_init.rs @@ -95,7 +95,7 @@ impl ClientInit { Err(err) => { match err { ClientError::Network(PostError::Bincode(_)) => { - last_err = Some(Error::ConnectionFailed(err)); + last_err = Some(Error::ClientError(err)); break 'tries; }, // Assume the connection failed and try again soon diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index aa50f7d19b..f4fb75a122 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -75,22 +75,48 @@ impl PlayState for MainMenuState { }, Some(InitMsg::Done(Err(err))) => { client_init = None; - global_state.info_message = Some( - match err { - InitError::BadAddress(_) | InitError::NoAddress => "Server not found", + global_state.info_message = Some({ + let err = match err { + InitError::BadAddress(_) | InitError::NoAddress => { + "Server not found".into() + }, InitError::ClientError(err) => match err { - client::Error::InvalidAuth => "Invalid credentials", - client::Error::TooManyPlayers => "Server is full", - client::Error::AuthServerNotTrusted => "Auth server not trusted", - _ => { - error!("Error when trying to connect: {:?}", err); - "Connection Failed" + client::Error::InvalidAuth => "Invalid credentials".into(), + client::Error::TooManyPlayers => "Server is full".into(), + client::Error::AuthServerNotTrusted => { + "Auth server not trusted".into() + }, + client::Error::ServerWentMad => "ServerWentMad: Probably versions \ + are incompatible, check for \ + updates." + .into(), + client::Error::ServerTimeout => "Timeout: Server did not respond \ + in time. (Overloaded or network \ + issues)." + .into(), + client::Error::ServerShutdown => "Server shut down".into(), + client::Error::AlreadyLoggedIn => { + "You are already logged into the server.".into() + }, + client::Error::Network(e) => format!("Network error: {:?}", e), + client::Error::Other(e) => format!("Error: {}", e), + client::Error::AuthClientError(e) => match e { + client::AuthClientError::JsonError(e) => { + format!("Fatal error: {}", e) + }, + client::AuthClientError::RequestError(e) => { + format!("Failed to send request to Auth server: {}", e) + }, + client::AuthClientError::ServerError(_, e) => format!("{}", e), }, }, - InitError::ClientCrashed => "Client crashed", - } - .to_string(), - ); + InitError::ClientCrashed => "Client crashed".into(), + }; + // Log error for possible additional use later or incase that the error + // displayed is cut of. + error!("{}", err); + err + }); }, Some(InitMsg::IsAuthTrusted(auth_server)) => { if global_state diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index cb7399ecc1..f56c8c309e 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -281,7 +281,7 @@ impl MainMenuUi { ) .font_id(self.fonts.cyri.conrod_id); let (frame_w, frame_h) = if let PopupType::AuthTrustPrompt(_) = popup_type { - (65.0 * 8.0, 300.0) + (65.0 * 8.0, 370.0) } else { (65.0 * 6.0, 140.0) }; @@ -747,8 +747,9 @@ impl MainMenuUi { self.popup = Some(PopupData { msg: format!( "Warning: The server you are trying to connect to has provided this \ - authentication server addresss:\n\n{}\n\nbut it is not in your list of trusted \ - authentication servers.", + authentication server address:\n\n{}\n\nbut it is not in your list of trusted \ + authentication servers.\n\nMake sure that you trust this site and owner to not \ + try and bruteforce your password!", &auth_server ), popup_type: PopupType::AuthTrustPrompt(auth_server),