From bf8f45bc876a931ae74ff9c5ef7eb32d6c80f9b6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 30 Dec 2020 11:49:04 +0000 Subject: [PATCH] Revert "attempt to split up OnlineError, wip" This reverts commit 52e8f7c84a7838d919e9cae37f52975bbd767851. --- daemon/api.rs | 23 ----------------------- src/error.rs | 25 +++++++++++++++++++++++++ src/global.rs | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/daemon/api.rs b/daemon/api.rs index 9286d588..37dab2f5 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -10,29 +10,6 @@ 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 e2134c2c..3f786208 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,6 +6,29 @@ 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")] @@ -88,6 +111,8 @@ 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 33850bc6..46aecdba 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: Copy; + type Error: Into; const ERROR : Self::Error; fn global_tokens(_:PrivateCaller) -> &'static RwLock>; fn tokens_registry(ig: &mut Instance, _:PrivateCaller) -- 2.30.2