[2016][rust][11.0] Better errors
change xsuwvykkvtkwntmpwzyuzxrqwqrwpwow
commit 30021204571d2e38e9b6d001aaf194dac7d89c5a
author Alpha Chen <alpha.chen@gmail.com>
date
parent ylytqwso
diff --git a/2016/rust/src/day_11.rs b/2016/rust/src/day_11.rs
index 5eb03e9..a1a0511 100644
--- a/2016/rust/src/day_11.rs
+++ b/2016/rust/src/day_11.rs
@@ -77,12 +77,12 @@ impl str::FromStr for Floor {
 impl<'a> TryFrom<regex::Captures<'a>> for Item {
     type Err = Error;
     fn try_from(c: regex::Captures) -> Result<Self> {
-        let element = c.name("element").ok_or("")?;
-        let itemtype = c.name("itemtype").ok_or("")?;
+        let element = c.name("element").ok_or("missing element name")?;
+        let itemtype = c.name("itemtype").ok_or("missing item type")?;
         match itemtype {
             "generator" => Ok(Item::Generator(element.into())),
             "microchip" => Ok(Item::Microchip(element.into())),
-            _ => Err("".into()),
+            _ => Err(format!("unexpected item type: '{}'", itemtype).into()),
         }
     }
 }