From fe3498e104295fa94631a9ac9e33568a64015330 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 13 Jul 2021 15:19:52 +0100 Subject: [PATCH] errors: Make BadStateForOperation be Ia Signed-off-by: Ian Jackson --- daemon/api.rs | 2 -- src/clock.rs | 6 +++--- src/error.rs | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/daemon/api.rs b/daemon/api.rs index 45e184a0..bb6053d1 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -78,8 +78,6 @@ impl From<&FatalErrorResponse> for rocket::http::Status { => Status::NotFound, OE::PieceHeld | OE::PieceImmoveable | OE::OverlappingOccultation | OE::Occultation | - OE::BadPieceStateForOperation - => Status::Conflict, BadOperation | BadJSON(_) => Status::BadRequest, } diff --git a/src/clock.rs b/src/clock.rs index 740ae2d2..2845431e 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -638,7 +638,7 @@ impl PieceTrait for Clock { }, "reset" => { if state.current.is_some() { - throw!(OE::BadPieceStateForOperation); + throw!(Ia::BadPieceStateForOperation); } state.reset(&self.spec); (Unpredictable, format!("reset")) @@ -646,7 +646,7 @@ impl PieceTrait for Clock { "claim-x" | "claim-y" => { let user = get_user(); if let Some(_gpl) = gs.players.get(state.users[user].player) { - throw!(OE::BadPieceStateForOperation); + throw!(Ia::BadPieceStateForOperation); } state.users[user].player = player; if state.users[! user].player == player { @@ -661,7 +661,7 @@ impl PieceTrait for Clock { (Unpredictable, format!("cleared player {} at the", user)) }, _ => { - throw!(OE::BadPieceStateForOperation); + throw!(Ia::BadPieceStateForOperation); } }; diff --git a/src/error.rs b/src/error.rs index 31c5d2e0..3242a0c6 100644 --- a/src/error.rs +++ b/src/error.rs @@ -26,8 +26,6 @@ pub enum Fatal { // Includes _bogus_ client updates, see PROTOCOL.md OverlappingOccultation, // xxx should be _inapplicable_ #[error("piece is occulting, or occulted")] Occultation, // xxx should be _inapplicable_ - #[error("UI operation not valid in the curret piece state")] - BadPieceStateForOperation, // xxx should be _inapplicable_ } #[derive(Error,Debug)] @@ -185,6 +183,8 @@ pub enum Inapplicable { #[error("piece may not be moved")] PieceImmoveable, #[error("occulter already rotated")] OcculterAlreadyRotated, #[error("overfull, cannot organise")] OrganisedPlacementOverfull, + #[error("UI operation not valid in the curret piece state")] + BadPieceStateForOperation, } pub type StartupError = anyhow::Error; -- 2.30.2