From: Ian Jackson Date: Sat, 13 Feb 2021 12:56:22 +0000 (+0000) Subject: abolish confusing SE type aliases X-Git-Tag: otter-0.4.0~515 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fd9f0322d27a7cd339111c7e744fb975add32e8d;p=otter.git abolish confusing SE type aliases Signed-off-by: Ian Jackson --- diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 24a2e868..b9e4cc33 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -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> = match count { Some(explicit) if implicit == 1 => { diff --git a/src/gamestate.rs b/src/gamestate.rs index f0c03bec..74a09c74 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -4,8 +4,6 @@ use crate::imports::*; -type SE = SVGProcessingError; - // ---------- newtypes and type aliases ---------- visible_slotmap_key!{ PlayerId(b'#') } @@ -275,7 +273,7 @@ impl 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, }; diff --git a/src/imports.rs b/src/imports.rs index b08cded4..aa1daaa6 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -132,6 +132,8 @@ pub type ESVU = ErrorSignaledViaUpdate; 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; diff --git a/src/pieces.rs b/src/pieces.rs index e91d2250..ba26b01e 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -10,8 +10,6 @@ use piece_specs::SimpleCommon; type ColourMap = IndexVec; -type SE = SVGProcessingError; - #[derive(Debug,Serialize,Deserialize)] // todo: this serialisation is rather large pub struct SimpleShape { @@ -47,7 +45,7 @@ impl From 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) -> Html { Html(format!("M {} {} h {} v {} h {} z", -x*0.5, -y*0.5, x, y, -x)) diff --git a/src/shapelib.rs b/src/shapelib.rs index c2e57364..671e4549 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -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 { 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,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(); diff --git a/src/spec.rs b/src/spec.rs index aee67249..0102bce3 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -312,7 +312,6 @@ pub mod implementation { use crate::imports::*; type AS = AccountScope; - type SE = SpecError; type TPS = TablePlayerSpec; impl AreaC { @@ -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

) -> 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 } }