use OnlineError::*;
match oe.0 {
ServerFailure(_) => Status::InternalServerError,
- NoClient | NoPlayer(_) | GameBeingDestroyed
+ NoClient | NoPlayer(_) | GameBeingDestroyed(_)
=> Status::NotFound,
OE::PieceHeld | OE::PieceImmoveable |
OE::OverlappingOccultation | OE::Occultation |
MustSpecifyNick,
AlreadyExists,
NickCollision,
- GameBeingDestroyed,
+ GameBeingDestroyed(#[from] GameBeingDestroyed),
GameNotFound,
GameCorrupted,
AccountNotFound(#[from] AccountNotFound),
}
}
-from_instance_lock_error!{MgmtError}
-
impl AccessTokenInfo {
pub fn report(self) -> Vec<String> {
vec![
#[derive(Error,Debug)]
pub enum OnlineError {
#[error("Game in process of being destroyed")]
- GameBeingDestroyed,
+ GameBeingDestroyed(#[from] GameBeingDestroyed),
#[error("client session not recognised (terminated by server?)")]
NoClient,
#[error("player not part of game (removed?)")]
#[error("UI operation not valid in the curret piece state")]
BadPieceStateForOperation,
}
-from_instance_lock_error!{OnlineError}
#[derive(Error,Debug)]
pub enum InternalError {
}
}
-#[derive(Error,Debug)]
-pub enum InstanceLockError {
- GameBeingDestroyed,
-}
-#[macro_export]
-macro_rules! from_instance_lock_error {
- ($into:ident) => {
- impl From<InstanceLockError> for $into {
- fn from(e: InstanceLockError) -> $into {
- use InstanceLockError::*;
- match e {
- GameBeingDestroyed => $into::GameBeingDestroyed,
- }
- }
- }
- }
-}
+#[derive(Error,Clone,Debug,Serialize,Deserialize)]
+#[error("game is being destroyed")]
+pub struct GameBeingDestroyed;
pub trait ById {
type Id;
pub links: Arc<LinksTable>,
}
-display_as_debug!{InstanceLockError}
-
pub struct PrivateCaller(());
// outsiders cannot construct this
// workaround for inability to have private trait methods
// ---------- Main API for instance lifecycle ----------
impl InstanceRef {
- #[throws(InstanceLockError)]
+ #[throws(GameBeingDestroyed)]
pub fn lock(&self) -> InstanceGuard<'_> {
let c = self.0.lock();
- if !c.live { throw!(InstanceLockError::GameBeingDestroyed) }
+ if !c.live { throw!(GameBeingDestroyed) }
InstanceGuard { c, gref: self.clone() }
}
}
impl<A> Unauthorised<InstanceRef, A> {
- #[throws(InstanceLockError)]
+ #[throws(GameBeingDestroyed)]
pub fn lock<'r>(&'r self) -> Unauthorised<InstanceGuard<'r>, A> {
let must_not_escape = self.by_ref(Authorisation::authorise_any());
Unauthorised::of(must_not_escape.lock()?)
pub use crate::dbgc;
pub use crate::{deref_to_field, deref_to_field_mut};
pub use crate::ensure_eq;
-pub use crate::from_instance_lock_error;
pub use crate::matches_doesnot;
pub use crate::trace_dbg;
pub use crate::{want, wantok, wants, want_let, want_failed_internal};