diff options
author | Katharina Fey <kookie@spacekookie.de> | 2021-02-14 00:06:14 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2021-02-14 00:06:14 +0100 |
commit | effbdeed66e8de8e769b8ac069926ad1a9110e62 (patch) | |
tree | e4522354e53266204aa9962caccde55d8c815092 /games/rstnode/rst-core/src/error.rs | |
parent | 5dab336049dbc6817e9ff212998690f59f6bbfa8 (diff) |
* Add an inbox/ outbox system to server components
* Define a data flow from Request -> computation -> Update
* Create simple handlers to call server or client code for requests
Diffstat (limited to 'games/rstnode/rst-core/src/error.rs')
-rw-r--r-- | games/rstnode/rst-core/src/error.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/games/rstnode/rst-core/src/error.rs b/games/rstnode/rst-core/src/error.rs new file mode 100644 index 000000000000..38c93bbe823f --- /dev/null +++ b/games/rstnode/rst-core/src/error.rs @@ -0,0 +1,51 @@ +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) + } +} |