From 148f22eccdc5c19c9140a80c5b63cf62ff82cae4 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Tue, 10 Jan 2017 08:35:29 -0800 Subject: [PATCH] [2016][rust][11.0] Better errors --- 2016/rust/src/day_11.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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> for Item { type Err = Error; fn try_from(c: regex::Captures) -> Result { - 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()), } } }