You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
pub use crate::wire::{AuthErr, LobbyErr, MatchErr, RegErr};
|
|
use serde::{Deserialize, Serialize};
|
|
use std::fmt::{self, Display, Formatter};
|
|
|
|
/// A wrapper around the different RST node errors that can occur
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum Error {
|
|
/// Failure in the registration process
|
|
Register(RegErr),
|
|
/// Failure in the authentication process
|
|
Auth(AuthErr),
|
|
/// Failure handling a lobby
|
|
Lobby(LobbyErr),
|
|
/// Failure in a match setting
|
|
Match(MatchErr),
|
|
}
|
|
|
|
impl std::error::Error for Error {}
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
write!(f, "An RST error")
|
|
}
|
|
}
|
|
|
|
/// A RST Node specific error
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
impl From<RegErr> for Error {
|
|
fn from(e: RegErr) -> Self {
|
|
Error::Register(e)
|
|
}
|
|
}
|
|
|
|
impl From<AuthErr> for Error {
|
|
fn from(e: AuthErr) -> Self {
|
|
Error::Auth(e)
|
|
}
|
|
}
|
|
|
|
impl From<LobbyErr> for Error {
|
|
fn from(e: LobbyErr) -> Self {
|
|
Error::Lobby(e)
|
|
}
|
|
}
|
|
|
|
impl From<MatchErr> for Error {
|
|
fn from(e: MatchErr) -> Self {
|
|
Error::Match(e)
|
|
}
|
|
}
|
|
|