chiark / gitweb /
errors: Make BadStateForOperation be Ia
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Jul 2021 14:19:52 +0000 (15:19 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Jul 2021 14:19:52 +0000 (15:19 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/api.rs
src/clock.rs
src/error.rs

index 45e184a0616a4f78365e0ddf15b85b27293e7d7a..bb6053d15376eaac75113c0a8f194428932a25d0 100644 (file)
@@ -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,
     }
index 740ae2d292a303bd36af1ca8d23d2838375efb9f..2845431ee4fb886eeee078749846348d913bef94 100644 (file)
@@ -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);
       }
     };
 
index 31c5d2e093f1ef9872e738dfa65152a52fd32015..3242a0c6d2112bfd1d40e925856f724911c7cfea 100644 (file)
@@ -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;