chiark / gitweb /
errors: Include error_msg in ESVU::PieceOpError
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Jul 2021 15:08:15 +0000 (16:08 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 13 Jul 2021 15:08:15 +0000 (16:08 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/error.rs
src/global.rs
src/prelude.rs
src/updates.rs

index dc0de331c924b90c9bbeeeaf94e73e6c8ea859ac..277e5359b27d1ccf709acb07588e6ba33b33959e 100644 (file)
@@ -142,12 +142,13 @@ impl From<InternalError> for ApiPieceOpError {
 }
 
 #[derive(Debug,Serialize,Clone)]
-pub enum ErrorSignaledViaUpdate<POEPU: Debug> {
+pub enum ErrorSignaledViaUpdate<POEPU: Debug, EM: Debug> {
   InternalError,
   PlayerRemoved, // appears only in streams for applicable player
   TokenRevoked, // appears only in streams for applicable player
   PieceOpError {
     error: Inapplicable,
+    error_msg: EM,
     partially: PieceOpErrorPartiallyProcessed,
     state: POEPU,
   },
index 31d99f42a8048f32bdf0ba47158cad8e24396357..4c1d9bd7348d9a9a425ee6e72da3c92065e2890c 100644 (file)
@@ -660,7 +660,7 @@ impl<'ig> InstanceGuard<'ig> {
 
   pub fn remove_clients(&mut self,
                         players: &HashSet<PlayerId>,
-                        signal: ErrorSignaledViaUpdate<PUE_P>) {
+                        signal: ErrorSignaledViaUpdate<PUE_P, String>) {
     let mut clients_to_remove = HashSet::new();
     self.clients.retain(|k,v| {
       let remove = players.contains(&v.player);
index bd6ef8cb24b9d62369ff51e4bbf45a1b9f9e83f0..1425ebc891cc706db556d344a306c0cf00c5f2d8 100644 (file)
@@ -194,7 +194,7 @@ pub type PUM = ProgressUpdateMode;
 
 // error.rs
 pub type APOE = ApiPieceOpError;
-pub type ESVU<POEPU> = ErrorSignaledViaUpdate<POEPU>;
+pub type ESVU<POEPU,EM> = ErrorSignaledViaUpdate<POEPU,EM>;
 pub type IE = InternalError;
 pub type Ia = Inapplicable;
 pub type POEPP = PieceOpErrorPartiallyProcessed;
index b01ed922e95047b31df788a26e7ede31d85b47d8..3c1cf29bf4a960d6d08295349a9c0e61542f8c58 100644 (file)
@@ -74,7 +74,7 @@ pub enum PreparedUpdateEntry {
     new_info_pane: Arc<Html>,
   },
   Log(Arc<CommittedLogEntry>),
-  Error(ErrorSignaledViaUpdate<PUE_P>),
+  Error(ErrorSignaledViaUpdate<PUE_P, String>),
 }
 
 #[allow(non_camel_case_types)]
@@ -255,7 +255,7 @@ enum TransmitUpdateEntry<'u> {
   SetLinks(Html),
   #[serde(serialize_with="serialize_logentry")]
   Log(TransmitUpdateLogEntry<'u>),
-  Error(ErrorSignaledViaUpdate<TUE_P<'u>>),
+  Error(ErrorSignaledViaUpdate<TUE_P<'u>, &'u str>),
 }
 
 type TransmitUpdateLogEntry<'u> = (&'u Timezone, &'u CommittedLogEntry);
@@ -628,7 +628,8 @@ impl<'r> PrepareUpdatesBuffer<'r> {
       }
     )?;
     let update = PUE::Error(ESVU::PieceOpError {
-      error, state, partially
+      error, state, partially,
+      error_msg: error.to_string(),
     });
     buf.us.push(update);
     buf.log_updates(logents);
@@ -870,7 +871,7 @@ impl PreparedUpdate {
   pub fn for_transmit<'u>(&'u self, tz: &'u Timezone,
                           player: PlayerId, dest: ClientId)
                           -> TransmitUpdate<'u> {
-    type ESVU<T> = ErrorSignaledViaUpdate<T>;
+    type ESVU<T,EM> = ErrorSignaledViaUpdate<T,EM>;
     type PUE = PreparedUpdateEntry;
     type TUE<'u> = TransmitUpdateEntry<'u>;
     let mut ents = vec![];
@@ -970,7 +971,8 @@ impl PreparedUpdate {
             ESVU::InternalError => TUE::Error(ESVU::InternalError),
             ESVU::PlayerRemoved => TUE::Error(ESVU::PlayerRemoved),
             ESVU::TokenRevoked  => TUE::Error(ESVU::TokenRevoked),
-            ESVU::PieceOpError { error, partially, ref state } => {
+            ESVU::PieceOpError { error, partially,
+                                 ref error_msg, ref state } => {
               let c = state.by_client.as_ref().map(|(_,c,_)| *c);
               if c == None || c == Some(dest) {
                 let state = match pue_piece_to_tue_p(state, player) {
@@ -978,7 +980,7 @@ impl PreparedUpdate {
                   None => continue,
                 };
                 TUE::Error(
-                  ESVU::PieceOpError { error, partially, state }
+                  ESVU::PieceOpError { error, error_msg, partially, state }
                 )
               } else {
                 match partially {