From 52e8f7c84a7838d919e9cae37f52975bbd767851 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 30 Dec 2020 11:44:00 +0000 Subject: [PATCH] attempt to split up OnlineError, wip Signed-off-by: Ian Jackson --- daemon/api.rs | 23 +++++++++++++++++++++++ src/error.rs | 25 ------------------------- src/global.rs | 2 +- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/daemon/api.rs b/daemon/api.rs index 37dab2f5..9286d588 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -10,6 +10,29 @@ type PL = PresentationLayout; pub struct AbbrevPresentationLayout(pub PresentationLayout); +#[derive(Error,Debug)] +pub enum OnlineError { + #[error("Game in process of being destroyed")] + GameBeingDestroyed, + #[error("client session not recognised (terminated by server?)")] + NoClient, + #[error("player not part of game (removed?)")] + NoPlayer(#[from] PlayerNotFound), + #[error("invalid Z coordinate")] + InvalidZCoord, + #[error("Server operational problems - consult administrator: {0:?}")] + ServerFailure(#[from] InternalError), + #[error("JSON deserialisation error: {0:?}")] + BadJSON(serde_json::Error), + #[error("referenced piece is gone (maybe race)")] + PieceGone, + #[error("improper piece hold status for op (maybe race)")] + PieceHeld, + #[error("improper UI operation")] + BadOperation, +} +from_instance_lock_error!{OnlineError} + /* impl<'r> FromParam<'r> for PresentationLayout { type Error = strum::ParseError; diff --git a/src/error.rs b/src/error.rs index 3f786208..e2134c2c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,29 +6,6 @@ use crate::imports::*; type IE = InternalError; -#[derive(Error,Debug)] -pub enum OnlineError { - #[error("Game in process of being destroyed")] - GameBeingDestroyed, - #[error("client session not recognised (terminated by server?)")] - NoClient, - #[error("player not part of game (removed?)")] - NoPlayer(#[from] PlayerNotFound), - #[error("invalid Z coordinate")] - InvalidZCoord, - #[error("Server operational problems - consult administrator: {0:?}")] - ServerFailure(#[from] InternalError), - #[error("JSON deserialisation error: {0:?}")] - BadJSON(serde_json::Error), - #[error("referenced piece is gone (maybe race)")] - PieceGone, - #[error("improper piece hold status for op (maybe race)")] - PieceHeld, - #[error("improper UI operation")] - BadOperation, -} -from_instance_lock_error!{OnlineError} - #[derive(Error,Debug)] pub enum InternalError { #[error("Game corrupted by previous crash")] @@ -111,8 +88,6 @@ display_as_debug!{PieceOpError} pub type StartupError = anyhow::Error; -pub use OnlineError::{NoClient,NoPlayer}; - #[derive(Error,Debug)] pub enum InstanceLockError { GameCorrupted, diff --git a/src/global.rs b/src/global.rs index 46aecdba..33850bc6 100644 --- a/src/global.rs +++ b/src/global.rs @@ -1096,7 +1096,7 @@ pub fn load_games(accounts: &mut AccountsGuard, pub type TokenTable = HashMap>; pub trait AccessId: Copy + Clone + 'static { - type Error: Into; + type Error: Copy; const ERROR : Self::Error; fn global_tokens(_:PrivateCaller) -> &'static RwLock>; fn tokens_registry(ig: &mut Instance, _:PrivateCaller) -- 2.30.2