chiark / gitweb /
attempt to split up OnlineError, wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 30 Dec 2020 11:44:00 +0000 (11:44 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 30 Dec 2020 11:44:54 +0000 (11:44 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/api.rs
src/error.rs
src/global.rs

index 37dab2f50232b16f721d50ea87124000adad19ee..9286d588ce8afe00993fbf12f947b601ab5ee924 100644 (file)
@@ -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;
index 3f78620891d49a880c3b5e23f63498535eb9e8ca..e2134c2c2bd3dfd7c1ef01a5806b7d7cf77174da 100644 (file)
@@ -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,
index 46aecdba780d3ba1eed7bc4b4e4d1aa503f1bf13..33850bc6033498982535e2c54e52691a2a0f45a6 100644 (file)
@@ -1096,7 +1096,7 @@ pub fn load_games(accounts: &mut AccountsGuard,
 pub type TokenTable<Id> = HashMap<RawToken, InstanceAccessDetails<Id>>;
 
 pub trait AccessId: Copy + Clone + 'static {
-  type Error: Into<OnlineError>;
+  type Error: Copy;
   const ERROR : Self::Error;
   fn global_tokens(_:PrivateCaller) -> &'static RwLock<TokenTable<Self>>;
   fn tokens_registry(ig: &mut Instance, _:PrivateCaller)