From: Ian Jackson Date: Sat, 26 Mar 2022 00:32:52 +0000 (+0000) Subject: Introduce InvalidAbbrevPresentationLayout error type X-Git-Tag: otter-1.0.0~131 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3203871d6b608b9dbb75ca39143424582e5e578c;p=otter.git Introduce InvalidAbbrevPresentationLayout error type Signed-off-by: Ian Jackson --- diff --git a/src/ui.rs b/src/ui.rs index 38be33c1..855099cd 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -74,14 +74,18 @@ impl Default for PresentationLayout { #[derive(Debug)] pub struct AbbrevPresentationLayout(pub PresentationLayout); +#[derive(Error,Debug,Clone,Copy)] +#[error("Invalid presentation layout character")] +pub struct InvalidAbbrevPresentationLayout; + impl FromStr for AbbrevPresentationLayout { - type Err = (); + type Err = InvalidAbbrevPresentationLayout; #[throws(Self::Err)] fn from_str(s: &str) -> Self { AbbrevPresentationLayout(match s { "p" => PL::Portrait, "l" => PL::Landscape, - _ => throw!(()) + _ => throw!(InvalidAbbrevPresentationLayout) }) } }