chiark / gitweb /
Introduce InvalidAbbrevPresentationLayout error type
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 26 Mar 2022 00:32:52 +0000 (00:32 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Mar 2022 22:03:22 +0000 (23:03 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/ui.rs

index 38be33c1162c9267d92d412f49fa5f4e68b147d5..855099cd75b0cb6558352d42c921c93af87ef977 100644 (file)
--- 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)
     })
   }
 }