From: Ian Jackson Date: Tue, 13 Jul 2021 14:19:52 +0000 (+0100) Subject: errors: Make BadStateForOperation be Ia X-Git-Tag: otter-0.7.2~123 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fe3498e104295fa94631a9ac9e33568a64015330;p=otter.git errors: Make BadStateForOperation be Ia Signed-off-by: Ian Jackson --- 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;