From 000097ef456df61e5223d41597e4c87710081fa4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 13 Jul 2021 15:26:20 +0100 Subject: [PATCH] errors: Make Ia::BadUiOperation Signed-off-by: Ian Jackson --- daemon/api.rs | 2 +- src/deck.rs | 2 +- src/error.rs | 3 +-- src/gamestate.rs | 2 +- src/hand.rs | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/daemon/api.rs b/daemon/api.rs index c35f1d6f..3fc6c348 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -77,7 +77,7 @@ impl From<&FatalErrorResponse> for rocket::http::Status { NoClient | NoPlayer(_) | GameBeingDestroyed(_) => Status::NotFound, OE::PieceHeld | OE::PieceImmoveable | - BadOperation | BadJSON(_) + BadJSON(_) => Status::BadRequest, } } diff --git a/src/deck.rs b/src/deck.rs index c47f53e3..48bbcbed 100644 --- a/src/deck.rs +++ b/src/deck.rs @@ -186,7 +186,7 @@ impl PieceTrait for Deck { "activate" => (Enabled, hformat!("enabled {}", CORE_DESC)), "counting" => (Counting, hformat!("set {} to counting", CORE_DESC)), "deactivate" => (Disabled, hformat!("disabled {}", CORE_DESC)), - _ => throw!(OE::BadOperation), + _ => throw!(Ia::BadUiOperation), }; let new_view = match new_state { diff --git a/src/error.rs b/src/error.rs index f22d1d51..5f0d73d0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -20,8 +20,6 @@ pub enum Fatal { // Includes _bogus_ client updates, see PROTOCOL.md PieceHeld, // xxx should be _inapplicable_ #[error("improper UI operation")] PieceImmoveable, // xxx should be _inapplicable_ - #[error("improper UI operation")] - BadOperation, // xxx should be _inapplicable_ } #[derive(Error,Debug)] @@ -180,6 +178,7 @@ pub enum Inapplicable { #[error("occulter already rotated")] OcculterAlreadyRotated, #[error("overfull, cannot organise")] OrganisedPlacementOverfull, #[error("overlapping occultation(s)")] OverlappingOccultation, + #[error("UI operation not recognised")] BadUiOperation, #[error("UI operation not valid in the curret piece state")] BadPieceStateForOperation, } diff --git a/src/gamestate.rs b/src/gamestate.rs index ef234c49..db930b2a 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -185,7 +185,7 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static { fn ui_operation(&self, _: ShowUnocculted, _a: ApiPieceOpArgs<'_>, _opname: &str, _wrc: WhatResponseToClientOp) -> Result { - throw!(OE::BadOperation) + throw!(Ia::BadUiOperation) } // #[throws] doesn't work here - fehler #todo diff --git a/src/hand.rs b/src/hand.rs index c7f1e70c..dd675fef 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -316,7 +316,7 @@ impl PieceTrait for Hand { throw!(OE::PieceHeld); } _ => { - throw!(OE::BadOperation); + throw!(Ia::BadUiOperation); } }; -- 2.30.2