2020-01-02 08:43:45 +00:00
|
|
|
use authc::AuthClientError;
|
2022-07-08 04:06:56 +00:00
|
|
|
use common_net::msg::DecodeError;
|
2021-02-21 23:48:30 +00:00
|
|
|
pub use network::{InitProtocolError, NetworkConnectError, NetworkError};
|
2020-07-01 09:51:37 +00:00
|
|
|
use network::{ParticipantError, StreamError};
|
2021-04-09 07:34:58 +00:00
|
|
|
use specs::error::Error as SpecsError;
|
2019-03-03 22:02:38 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
2021-03-01 20:29:18 +00:00
|
|
|
Kicked(String),
|
2020-07-01 07:30:38 +00:00
|
|
|
NetworkErr(NetworkError),
|
|
|
|
ParticipantErr(ParticipantError),
|
|
|
|
StreamErr(StreamError),
|
2019-03-05 18:39:18 +00:00
|
|
|
ServerTimeout,
|
2019-03-03 22:02:38 +00:00
|
|
|
ServerShutdown,
|
2019-07-01 11:19:26 +00:00
|
|
|
TooManyPlayers,
|
2020-06-24 15:27:18 +00:00
|
|
|
NotOnWhitelist,
|
2020-01-07 06:27:18 +00:00
|
|
|
AuthErr(String),
|
2020-01-02 08:43:45 +00:00
|
|
|
AuthClientError(AuthClientError),
|
2021-03-11 00:08:12 +00:00
|
|
|
AuthServerUrlInvalid(String),
|
2020-01-02 08:43:45 +00:00
|
|
|
AuthServerNotTrusted,
|
2021-05-17 17:32:26 +00:00
|
|
|
HostnameLookupFailed(std::io::Error),
|
2020-07-31 03:34:35 +00:00
|
|
|
Banned(String),
|
2020-05-11 10:06:53 +00:00
|
|
|
/// Persisted character data is invalid or missing
|
|
|
|
InvalidCharacter,
|
2019-07-05 12:16:08 +00:00
|
|
|
//TODO: InvalidAlias,
|
2019-03-03 22:02:38 +00:00
|
|
|
Other(String),
|
2021-04-09 07:34:58 +00:00
|
|
|
SpecsErr(SpecsError),
|
2022-07-08 04:06:56 +00:00
|
|
|
CompressionError(DecodeError),
|
2021-04-09 07:34:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<SpecsError> for Error {
|
|
|
|
fn from(err: SpecsError) -> Self { Self::SpecsErr(err) }
|
2019-03-03 22:02:38 +00:00
|
|
|
}
|
|
|
|
|
2020-07-01 07:30:38 +00:00
|
|
|
impl From<NetworkError> for Error {
|
|
|
|
fn from(err: NetworkError) -> Self { Self::NetworkErr(err) }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<ParticipantError> for Error {
|
|
|
|
fn from(err: ParticipantError) -> Self { Self::ParticipantErr(err) }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<StreamError> for Error {
|
|
|
|
fn from(err: StreamError) -> Self { Self::StreamErr(err) }
|
2020-01-02 08:43:45 +00:00
|
|
|
}
|
|
|
|
|
2022-06-30 04:52:04 +00:00
|
|
|
impl From<bincode::Error> for Error {
|
|
|
|
fn from(err: bincode::Error) -> Self { Self::StreamErr(StreamError::Deserialize(err)) }
|
|
|
|
}
|
|
|
|
|
2022-07-08 04:06:56 +00:00
|
|
|
impl From<DecodeError> for Error {
|
|
|
|
fn from(err: DecodeError) -> Self {
|
|
|
|
match err {
|
|
|
|
DecodeError::Deserialize(err) => Self::StreamErr(StreamError::Deserialize(err)),
|
|
|
|
_ => Self::CompressionError(err),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-02 08:43:45 +00:00
|
|
|
impl From<AuthClientError> for Error {
|
|
|
|
fn from(err: AuthClientError) -> Self { Self::AuthClientError(err) }
|
2019-03-03 22:02:38 +00:00
|
|
|
}
|