From d222602d7a8ab55f5a5e7181b34c7e71ee128c27 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 13 Jul 2021 15:23:13 +0100 Subject: [PATCH] errors: Make create_occultation return APOE, and change Overlapping Signed-off-by: Ian Jackson --- daemon/api.rs | 1 - src/error.rs | 3 +-- src/hidden.rs | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/daemon/api.rs b/daemon/api.rs index 35720a55..59e3f140 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -77,7 +77,6 @@ impl From<&FatalErrorResponse> for rocket::http::Status { NoClient | NoPlayer(_) | GameBeingDestroyed(_) => Status::NotFound, OE::PieceHeld | OE::PieceImmoveable | - OE::OverlappingOccultation | BadOperation | BadJSON(_) => Status::BadRequest, } diff --git a/src/error.rs b/src/error.rs index 6c0b8251..f22d1d51 100644 --- a/src/error.rs +++ b/src/error.rs @@ -22,8 +22,6 @@ pub enum Fatal { // Includes _bogus_ client updates, see PROTOCOL.md PieceImmoveable, // xxx should be _inapplicable_ #[error("improper UI operation")] BadOperation, // xxx should be _inapplicable_ - #[error("overlapping occultation")] - OverlappingOccultation, // xxx should be _inapplicable_ } #[derive(Error,Debug)] @@ -181,6 +179,7 @@ pub enum Inapplicable { #[error("piece may not be moved")] PieceImmoveable, #[error("occulter already rotated")] OcculterAlreadyRotated, #[error("overfull, cannot organise")] OrganisedPlacementOverfull, + #[error("overlapping occultation(s)")] OverlappingOccultation, #[error("UI operation not valid in the curret piece state")] BadPieceStateForOperation, } diff --git a/src/hidden.rs b/src/hidden.rs index 3b9d45f5..f291e938 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -881,7 +881,7 @@ impl OccultationViewDef for OwnerOccultationView { } } } -#[throws(Fatal)] +#[throws(APOE)] pub fn create_occultation( gen: &mut UniqueGenGen, max_z: &mut ZLevel, @@ -925,7 +925,7 @@ pub fn create_occultation( } for occ in goccults.occults.values() { - if occ.region.overlaps(®ion) { throw!(OE::OverlappingOccultation) } + if occ.region.overlaps(®ion) { throw!(Ia::OverlappingOccultation) } } let mut recalc = vec![]; -- 2.30.2