chiark / gitweb /
abolish confusing SE type aliases
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Feb 2021 12:56:22 +0000 (12:56 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Feb 2021 12:56:22 +0000 (12:56 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs
src/gamestate.rs
src/imports.rs
src/pieces.rs
src/shapelib.rs
src/spec.rs

index 24a2e8687c14c6073144210cc397eb070af1c6a2..b9e4cc338999da3fd43be676ab20b0833c9a762c 100644 (file)
@@ -16,7 +16,6 @@ use std::os::unix::io::AsRawFd;
 use std::os::unix::net::UnixListener;
 use uds::UnixStreamExt;
 
-type SE = SpecError;
 type CSE = anyhow::Error;
 
 type TP = TablePermission;
@@ -569,7 +568,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
       let gs = &mut ig.gs;
       let implicit: u32 = info.count()
         .try_into().map_err(
-          |_| SE::InternalError(format!("implicit item count out of range"))
+          |_| SpE::InternalError(format!("implicit item count out of range"))
         )?;
       let count: Box<dyn ExactSizeIterator<Item=u32>> = match count {
         Some(explicit) if implicit == 1 => {
index f0c03bec4dc5408c20164a52ebd5adb186467290..74a09c74abdf507ce02bef7cdec8dfc7314efbcc 100644 (file)
@@ -4,8 +4,6 @@
 
 use crate::imports::*;
 
-type SE = SVGProcessingError;
-
 // ---------- newtypes and type aliases ----------
 
 visible_slotmap_key!{ PlayerId(b'#') }
@@ -275,7 +273,7 @@ impl<T> PieceExt for T where T: Piece + ?Sized {
   fn make_defs(&self, pri: &PieceRenderInstructions) -> Html {
     let mut defs = Html(String::new());
     let dragraise = match self.thresh_dragraise(pri)? {
-      Some(n) if n < 0 => throw!(SE::NegativeDragraise),
+      Some(n) if n < 0 => throw!(SvgE::NegativeDragraise),
       Some(n) => n,
       None => -1,
     };
index b08cded498369246805e3bfbeb78cf20c7b67cf8..aa1daaa64d15e60ca9fa22ce70431db7392f5ba3 100644 (file)
@@ -132,6 +132,8 @@ pub type ESVU<POEPU> = ErrorSignaledViaUpdate<POEPU>;
 pub type IE = InternalError;
 pub type OE = OnlineError;
 pub type POEPP = PieceOpErrorPartiallyProcessed;
+pub type SvgE = SVGProcessingError;
+pub type SpE = SpecError;
 
 // updates.rs
 pub type PUE = PreparedUpdateEntry;
index e91d22502cb8ecd8b0145afc8da1c5757a684e4f..ba26b01e38974689a973a3e2d5e58da55957d34b 100644 (file)
@@ -10,8 +10,6 @@ use piece_specs::SimpleCommon;
 
 type ColourMap = IndexVec<FaceId, Colour>;
 
-type SE = SVGProcessingError;
-
 #[derive(Debug,Serialize,Deserialize)]
 // todo: this serialisation is rather large
 pub struct SimpleShape {
@@ -47,7 +45,7 @@ impl From<SVGProcessingError> for MgmtError {
   fn from(se: SVGProcessingError) -> MgmtError { se.into() }
 }
 
-#[throws(SE)]
+#[throws(SvgE)]
 pub fn svg_rescale_path(input: &Html, scale: f64) -> Html {
   type BM = u64;
   type BI = u32;
@@ -87,7 +85,7 @@ pub fn svg_rescale_path(input: &Html, scale: f64) -> Html {
           continue;
         }
       }
-      _ => throw!(SE::UnknownOperator),
+      _ => throw!(SvgE::UnknownOperator),
     };
     write!(&mut out, "{}", w)?;
   }
@@ -96,7 +94,7 @@ pub fn svg_rescale_path(input: &Html, scale: f64) -> Html {
   Html(out)
 }
 
-#[throws(SE)]
+#[throws(SvgE)]
 pub fn svg_circle_path(diam: f64) -> Html {
   let unit_path = Html::lit(
     "M 0 1  a 1 1 0 1 0 0 -2 \
@@ -107,7 +105,7 @@ pub fn svg_circle_path(diam: f64) -> Html {
   path
 }
 
-#[throws(SE)]
+#[throws(SvgE)]
 pub fn svg_rectangle_path(PosC([x,y]): PosC<f64>) -> Html {
   Html(format!("M {} {} h {} v {} h {} z",
                -x*0.5, -y*0.5, x, y, -x))
index c2e573640052c25fd311026fb5513f836d3ca9a6..671e4549c8c172c9e3c1fb4fdb59a4ed5cf812be 100644 (file)
@@ -91,7 +91,6 @@ impl LibraryLoadError {
 const INHERIT_DEPTH_LIMIT: u8 = 20;
 
 type TV = toml::Value;
-type SE = SpecError;
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct ItemSpec {
@@ -192,7 +191,7 @@ pub fn libs_lookup(libname: &str)
       libs.as_ref()?.get(libname)?
     }))()
   })
-    .map_err(|_| SE::LibraryNotFound)
+    .map_err(|_| SpE::LibraryNotFound)
     ?
 }
 
@@ -201,7 +200,7 @@ impl ItemSpec {
   pub fn load(&self) -> Box<dyn Piece> {
     let lib = libs_lookup(&self.lib)?;
     let idata = lib.items.get(&self.item)
-      .ok_or(SE::LibraryItemNotFound(self.item.clone()))?;
+      .ok_or(SpE::LibraryItemNotFound(self.item.clone()))?;
     lib.load1(idata, &self.item)?
   }
 }
@@ -214,15 +213,15 @@ impl Contents {
       .map_err(|e| if e.kind() == ErrorKind::NotFound {
         warn!("library item lib={} itme={} data file {:?} not found",
               &self.libname, &name, &svg_path);
-        SE::LibraryItemNotFound(name.to_owned())
+        SpE::LibraryItemNotFound(name.to_owned())
       } else {
         let m = "error accessing/reading library item data file";
         error!("{}: {}: {}", &m, &svg_path, &e);
-        SE::InternalError(m.to_string())
+        SpE::InternalError(m.to_string())
       })?;
 
     idata.group.d.outline.check(&idata.group)
-      .map_err(|e| SE::InternalError(format!("rechecking outline: {}",&e)))?;
+      .map_err(|e| SpE::InternalError(format!("rechecking outline: {}",&e)))?;
     let outline = idata.group.d.outline.load(&idata.group)?;
 
     let mut svgs = IndexVec::with_capacity(1);
@@ -285,7 +284,7 @@ impl PieceSpec for MultiSpec {
   fn count(&self) -> usize { self.items.len() }
   fn load(&self, i: usize) -> Result<Box<dyn Piece>,SpecError> {
     let item = self.items.get(i).ok_or_else(
-      || SE::InternalError(format!("item {:?} from {:?}", i, &self))
+      || SpE::InternalError(format!("item {:?} from {:?}", i, &self))
     )?;
     let item = format!("{}{}{}", &self.prefix, item, &self.suffix);
     let lib = self.lib.clone();
index aee67249cb9577b3efee5cfbe5b29a19a5f5764d..0102bce3c94941aa0020bc511c1d3574371229f0 100644 (file)
@@ -312,7 +312,6 @@ pub mod implementation {
   use crate::imports::*;
 
   type AS = AccountScope;
-  type SE = SpecError;
   type TPS = TablePlayerSpec;
 
   impl<T> AreaC<T> {
@@ -333,7 +332,7 @@ pub mod implementation {
     #[throws(SpecError)]
     fn try_from(v: u8) -> Self {
       if v < 8 { Self(v) }
-      else { throw!(SE::CompassAngleInvalid) }
+      else { throw!(SpE::CompassAngleInvalid) }
     }
   }
 
@@ -358,9 +357,9 @@ pub mod implementation {
     fn try_from(ents: RawAcl<P>) -> Self {
       for ent in &ents {
         glob::Pattern::new(&ent.account_glob)
-          .map_err(|_| SE::AclInvalidAccountGlob)?;
+          .map_err(|_| SpE::AclInvalidAccountGlob)?;
         if ! ent.deny.is_disjoint(&ent.allow) {
-          throw!(SE::AclEntryOverlappingAllowDeny);
+          throw!(SpE::AclEntryOverlappingAllowDeny);
         }
       }
       Acl { ents }
@@ -604,7 +603,7 @@ pub mod implementation {
     #[throws(SpecError)]
     fn try_from(spec: &UrlSpec) -> Url {
       if spec.0.len() > UrlSpec::MAX_LEN {
-        throw!(SE::UrlTooLong);
+        throw!(SpE::UrlTooLong);
       }
       let base = Url::parse(&config().public_url)
         .or_else(|_| Url::parse(
@@ -613,7 +612,7 @@ pub mod implementation {
       let url = Url::options()
         .base_url(Some(&base))
         .parse(&spec.0)
-        .map_err(|_| SE::BadUrlSyntax)?;
+        .map_err(|_| SpE::BadUrlSyntax)?;
       url
     }
   }