chiark / gitweb /
errors: Make create_occultation return APOE, and change Overlapping
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Jul 2021 14:23:13 +0000 (15:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Jul 2021 14:23:13 +0000 (15:23 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/api.rs
src/error.rs
src/hidden.rs

index 35720a55da7fa1166becbc20a5464333641576bc..59e3f1402511c201e137556ca83bad157ad7571d 100644 (file)
@@ -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,
     }
index 6c0b825110395cce90d377b2385e1ec28875ae75..f22d1d51247673cf3396f2a09055094facbafa0c 100644 (file)
@@ -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,
 }
index 3b9d45f51ff0ab8d296794629d624033241d6b05..f291e938407c208f881da9946853a71f5eb76cb7 100644 (file)
@@ -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(&region) { throw!(OE::OverlappingOccultation) }
+    if occ.region.overlaps(&region) { throw!(Ia::OverlappingOccultation) }
   }
 
   let mut recalc = vec![];