use authc::AuthClientError; use common_net::msg::DecodeError; pub use network::{InitProtocolError, NetworkConnectError, NetworkError}; use network::{ParticipantError, StreamError}; use specs::error::Error as SpecsError; #[derive(Debug)] pub enum Error { Kicked(String), NetworkErr(NetworkError), ParticipantErr(ParticipantError), StreamErr(StreamError), ServerTimeout, ServerShutdown, TooManyPlayers, NotOnWhitelist, AuthErr(String), AuthClientError(AuthClientError), AuthServerUrlInvalid(String), AuthServerNotTrusted, HostnameLookupFailed(std::io::Error), Banned(String), /// Persisted character data is invalid or missing InvalidCharacter, //TODO: InvalidAlias, Other(String), SpecsErr(SpecsError), CompressionError(DecodeError), } impl From for Error { fn from(err: SpecsError) -> Self { Self::SpecsErr(err) } } impl From for Error { fn from(err: NetworkError) -> Self { Self::NetworkErr(err) } } impl From for Error { fn from(err: ParticipantError) -> Self { Self::ParticipantErr(err) } } impl From for Error { fn from(err: StreamError) -> Self { Self::StreamErr(err) } } impl From for Error { fn from(err: bincode::Error) -> Self { Self::StreamErr(StreamError::Deserialize(err)) } } impl From for Error { fn from(err: DecodeError) -> Self { match err { DecodeError::Deserialize(err) => Self::StreamErr(StreamError::Deserialize(err)), _ => Self::CompressionError(err), } } } impl From for Error { fn from(err: AuthClientError) -> Self { Self::AuthClientError(err) } }