From: Ian Jackson Date: Tue, 13 Jul 2021 14:21:52 +0000 (+0100) Subject: errors: Abolish Fatal::Occultation X-Git-Tag: otter-0.7.2~122 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=710122aa2b3c09c7a7eaacabbb90a330e632cb67;p=otter.git errors: Abolish Fatal::Occultation Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index bb6053d1..35720a55 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 | - OE::OverlappingOccultation | OE::Occultation | + OE::OverlappingOccultation | BadOperation | BadJSON(_) => Status::BadRequest, } @@ -448,7 +448,7 @@ api_route!{ let ApiPieceOpArgs { gs,piece, .. } = a; let gpc = gs.pieces.byid_mut(piece).unwrap(); if gpc.occult.is_active() { - if self.z >= gpc.zlevel.z { throw!(OE::Occultation) } + if self.z >= gpc.zlevel.z { throw!(Ia::Occultation) } } gpc.zlevel = ZLevel { z: self.z.clone(), zg: gs.gen }; let update = PieceUpdateOp::SetZLevel(()); diff --git a/src/error.rs b/src/error.rs index 3242a0c6..6c0b8251 100644 --- a/src/error.rs +++ b/src/error.rs @@ -24,8 +24,6 @@ pub enum Fatal { // Includes _bogus_ client updates, see PROTOCOL.md BadOperation, // xxx should be _inapplicable_ #[error("overlapping occultation")] OverlappingOccultation, // xxx should be _inapplicable_ - #[error("piece is occulting, or occulted")] - Occultation, // xxx should be _inapplicable_ } #[derive(Error,Debug)] diff --git a/src/hidden.rs b/src/hidden.rs index f768fb0f..3b9d45f5 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -455,9 +455,9 @@ impl GPiece { self.occult.active.is_some() } - #[throws(OE)] + #[throws(Ia)] pub fn forbid_involved_in_occultation(&self) { - if self.involved_in_occultation() { throw!(OE::Occultation) } + if self.involved_in_occultation() { throw!(Ia::Occultation) } } }