chiark / gitweb /
Revert "attempt to split up OnlineError, wip"
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 30 Dec 2020 11:49:04 +0000 (11:49 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 30 Dec 2020 11:49:04 +0000 (11:49 +0000)
This reverts commit 52e8f7c84a7838d919e9cae37f52975bbd767851.

daemon/api.rs
src/error.rs
src/global.rs

index 9286d588ce8afe00993fbf12f947b601ab5ee924..37dab2f50232b16f721d50ea87124000adad19ee 100644 (file)
@@ -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;
index e2134c2c2bd3dfd7c1ef01a5806b7d7cf77174da..3f78620891d49a880c3b5e23f63498535eb9e8ca 100644 (file)
@@ -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,
index 33850bc6033498982535e2c54e52691a2a0f45a6..46aecdba780d3ba1eed7bc4b4e4d1aa503f1bf13 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: Copy;
+  type Error: Into<OnlineError>;
   const ERROR : Self::Error;
   fn global_tokens(_:PrivateCaller) -> &'static RwLock<TokenTable<Self>>;
   fn tokens_registry(ig: &mut Instance, _:PrivateCaller)