From 908104ec1c2025d64ba4059db7162ca424f87346 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 16 Feb 2020 18:26:57 -0500 Subject: [PATCH] Properly implement percentage() error messages --- src/builtin/math.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/builtin/math.rs b/src/builtin/math.rs index 16fa276..d61b73a 100644 --- a/src/builtin/math.rs +++ b/src/builtin/math.rs @@ -9,7 +9,8 @@ pub(crate) fn register(f: &mut BTreeMap) { max_args!(args, 1); let num = match arg!(args, 0, "number").eval() { Value::Dimension(n, Unit::None) => n * Number::from(100), - _ => todo!("expected unitless number in builtin function `percentage()`") + v @ Value::Dimension(..) => return Err(format!("$number: Expected {} to have no units.", v).into()), + v => return Err(format!("$number: {} is not a number.", v).into()), }; Ok(Value::Dimension(num, Unit::Percent)) });