chiark / gitweb /
reorg error
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 31 Jul 2020 21:43:21 +0000 (22:43 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 31 Jul 2020 21:43:21 +0000 (22:43 +0100)
src/error.rs
src/updates.rs

index 1ec7908c6c74c238be13a6495485375ab38312e5..a9d243fd43f00dd93a2dac6adfb54c58f0eeffb8 100644 (file)
@@ -42,6 +42,12 @@ pub enum ServerFailure {
   MessagePackDecodeFail(#[from] rmp_serde::decode::Error),
 }
 
+#[derive(Error,Debug,Serialize,Copy,Clone)]
+pub enum ErrorSignaledViaUpdate {
+  RenderingError,
+}
+display_as_debug!{ErrorSignaledViaUpdate}
+
 pub type StartupError = anyhow::Error;
 
 pub use OnlineError::{NoClient,NoPlayer};
index b33142d40e566f8365940ac6ca18bf876f8c3f20..1dde1b619798f87ee90ada5c6939881353ce756d 100644 (file)
@@ -33,7 +33,7 @@ pub enum PreparedUpdateEntry {
     op : PieceUpdateOp<PreparedPieceState>,
   },
   Log (Arc<LogEntry>),
-  RenderingError,
+  Error (ErrorSignaledViaUpdate),
 }
 
 #[derive(Debug,Serialize)]
@@ -76,7 +76,7 @@ enum TransmitUpdateEntry<'u> {
     op : &'u PieceUpdateOp<PreparedPieceState>,
   },
   Log (&'u LogEntry),
-  ServerUpdateGenerationError,
+  Error(ErrorSignaledViaUpdate),
 }
 
 // ========== implementation ==========
@@ -113,10 +113,10 @@ impl PreparedUpdateEntry {
       },
       Log(logent) => {
         logent.html.as_bytes().len() * 3
-      }
-      RenderingError => {
+      },
+      Error(_) => {
         100
-      }
+      },
     }
   }
 }
@@ -247,7 +247,7 @@ impl<'r> PrepareUpdatesBuffer<'r> {
       .unwrap_or_else(|e| {
         eprintln!("piece update error! piece={:?} lens={:?} error={:?}",
                   piece, &lens, &e);
-        PreparedUpdateEntry::RenderingError
+        PreparedUpdateEntry::Error(ErrorSignaledViaUpdate::RenderingError)
       });
     self.us.push(update);
   }
@@ -297,8 +297,8 @@ impl PreparedUpdate {
         PreparedUpdateEntry::Log(logent) => {
           TransmitUpdateEntry::Log(&logent)
         },
-        PreparedUpdateEntry::RenderingError => {
-          TransmitUpdateEntry::ServerUpdateGenerationError
+        &PreparedUpdateEntry::Error(e) => {
+          TransmitUpdateEntry::Error(e)
         }
       };
       ents.push(ue);